Scheme pass-by-reference

前端 未结 7 1478
忘了有多久
忘了有多久 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 12:00

    See http://community.schemewiki.org/?scheme-faq-language question "Is there a way to emulate call-by-reference?".

    In general I think that fights against scheme's functional nature so probably there is a better way to structure the program to make it more scheme-like.

提交回复
热议问题