Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Scheme > letrec set! sur...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4545 of 4665
Post > Topic >>

letrec set! surprise

by Ramana <ramana.kumar@[EMAIL PROTECTED] > Jun 10, 2008 at 01:41 PM

When the body of a letrec is a function (the function "bar" below),
failure to perform an inverse-eta expansion on it can have some
surprising consequences. Note that we are not using eta reduction for
its common use of delaying a computation; instead the reduction
eliminates a closure whose environment, it turns out, is very
im****tant. Is this a case where the language ought to match our
intuitions better?

(let
  ([foo (letrec
          ([bar
             (lambda (a)
               (set! bar
                 (lambda (a) 1))
               a)])
          bar)])
  (write (foo 0))
  (write (foo 0)))
; writes "00", despite the set!

(let
  ([foo (letrec
          ([bar
             (lambda (a)
               (set! bar
                 (lambda (a) 1))
               a)])
          (lambda (a) (bar a)))])
  (write (foo 0))
  (write (foo 0)))
; writes "01", as expected
 




 3 Posts in Topic:
letrec set! surprise
Ramana <ramana.kumar@[  2008-06-10 13:41:07 
Re: letrec set! surprise
Matthias Blume <blume@  2008-06-10 16:17:31 
Re: letrec set! surprise
Ramana <ramana.kumar@[  2008-06-10 15:16:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 13:17:03 CDT 2008.