Variable references in lisp

前端 未结 7 829
灰色年华
灰色年华 2020-11-29 07:04

Another newbie (Common) LISP question:

Basically in most programming languages there\'s a mean for functions to receive references to variables instead of just value

相关标签:
7条回答
  • 2020-11-29 08:09

    You can produce similar effect by using return values, this is a possible design pattern in Lisp, even though it is not passing a variable by reference.

    Like this:

    (defun increase (subject increment)
      (+ subject increment))
    
    (let ((my-var 0))
      (message "Initial value: %s" my-var)
      (setq my-var (increase my-var 25))
      (message "Final value: %s" my-var))
    
    0 讨论(0)
提交回复
热议问题