Scheme pass-by-reference

前端 未结 7 1472
忘了有多久
忘了有多久 2021-02-08 11:09

How can I pass a variable by reference in scheme?

An example of the functionality I want:

(define foo
  (lambda (&x)
    (set! x 5)))

(define y 2)

         


        
7条回答
  •  一整个雨季
    2021-02-08 11:53

    You probably have use too much of C, PHP or whatever. In scheme you don't want to do stuff like pass-by-*. Understand first what scope mean and how the different implementation behave (in particular try to figure out what is the difference between LISP and Scheme).

    By essence a purely functional programming language do not have side effect. Consequently it mean that pass-by-ref is not a functional concept.

提交回复
热议问题