Created
May 10, 2015 19:03
-
-
Save beoliver/8622ee410df41b4ab3a9 to your computer and use it in GitHub Desktop.
let vs define
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > (define (foo) | |
| (let ((xs '(1 2 3))) | |
| (define (f) | |
| (set! xs 0)) | |
| (f) | |
| xs)) | |
| > (foo) | |
| 0 | |
| > (define (bar) | |
| (define (f) | |
| (set! xs 0)) | |
| (define xs '(1 2 3)) | |
| (f) | |
| xs) | |
| > (bar) | |
| 0 | |
| > (define (baz) | |
| (define (f) | |
| (set! xs 0)) | |
| (let ((xs '(1 2 3))) | |
| (f) | |
| xs)) | |
| > (baz) | |
| set!: assignment disallowed; | |
| cannot set undefined | |
| variable: xs | |
| context...: | |
| stdin::13854: baz | |
| /Applications/Racket v6.0/collects/racket/private/misc.rkt:87:7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment