> On Sep 29, 2015, at 7:20 PM, Brian Mastenbrook <[email protected]> wrote:
> 
> After playing with various permutations of this, I encountered a behavior 
> that seems like a clear violation of referential transparency:
> 
> (define x 'outer)
> 
> (define-syntax-rule (def-m m given-x)
>  (define-syntax-rule (m)
>    (begin
>      (define given-x 'inner)
>      x)))
> 
> (def-m m x)
> (let ()
>  (m))
> 
> Under the old expander, this yields 'outer; under the new expander, it yields 
> 'inner. Under both expanders, the following yields 'outer:

Up to this point, I would have said “obvious, let me explain” but the idea that 
wrapping a let () around the last expression changes its expansion blew my 
mind. I’d say it’s a bug. 

Think of the two-directional substitution I mentioned in Manifesto. Here is the 
next step: 

(define x 'outer)

(define-syntax-rule
  (def-m m given-x)
  (define-syntax-rule
    (m)
    (begin
      (define given-x 'inner)
      x)))

(define-syntax-rule
    (m)
    (begin
      (define x ‘inner) ;; <— the ‘x’ that is placed here is *the* x that is 
define-d above 
;; you want this to catch the next x because it is the *same* x and it was 
explicitly passed in 
      x))

(let ()
    (m))

So I will wait for Matthew to explain the let-wrapped expression. — Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/0BA60CDF-B8AD-414A-AD61-C40B62F3D065%40ccs.neu.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to