home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7055 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1.3 KB

  1. Xref: sparky comp.lang.perl:7055 comp.lang.scheme:2608 comp.lang.tcl:1880
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!olivea!charnel!psgrain!percy!data!kend
  3. From: kend@data.rain.com (Ken Dickey)
  4. Newsgroups: comp.lang.perl,comp.lang.scheme,comp.lang.tcl
  5. Subject: Re^2: Closures, Object-Oriented Equivalence, New version of Perl and TCL
  6. Message-ID: <736@data.rain.com>
  7. Date: 19 Nov 92 00:56:35 GMT
  8. References: <9211110521.AA01343@cs.columbia.edu> <9211180509.AA04035@cs.columbia.edu>
  9. Organization: Microtek DSD, Hillsboro, OR
  10. Lines: 37
  11.  
  12. thayer@cs.columbia.edu (Charles Thayer) writes:
  13.  
  14. >:)  Which brings up an interesting point in mit-scheme:
  15.  
  16. >(begin
  17. >  (define a "moo")
  18. >  (define (foo) 
  19. >    (display a)
  20. >    (define a "bar")
  21. >    )
  22. >  (foo))
  23.  
  24. >=> Unassigned variable a
  25.  
  26.  
  27. This is because the above is equivalent to the following:
  28.  
  29. (letrec ( (a "moo")
  30.           (foo 
  31.             (lambda ()
  32.              (display a)
  33.                  (define a "bar")) ;; <- ill-placed define
  34.           )
  35.         )
  36.   (foo)
  37. )
  38.  
  39. The semantics of "internal defines" is that of LETREC (parallel
  40. assignment) and
  41. *** definitions must occur before other expressions within a block ***
  42.  
  43. This difference between "internal defines" and "top-level defines"
  44. has been a subject of debate for some time.  I am not taking a
  45. position here, just trying to insure that the definition is
  46. understood.
  47.  
  48. -Ken
  49.