[racket] tutorial: exploring the boundaries of outer space
On 04/10/2012 03:33 PM, Danny Yoo wrote:
> Hi everyone,
>
> Here's a tutorial that shows how to use Racket macros to create a
> lexical-scoping hole.
>
> http://hashcollision.org/outer-tutorial/index.html
>
> The tutorial is intended to be an introduction to Racket's macro system as well.
>
>
> Any suggestions and comments would be greatly appreciated. Thanks!
I find it interesting that you used a separate syntax parameter instead
of just making `outer' the syntax parameter. I think that the semantics
are the same with either strategy, but for some reason the latter seems
more obvious to me - perhaps because it's closest to the
non-syntax-parameterized version of this macro, and avoids the need for
`syntax-parameter-value' entirely.
Can you elaborate on why you used `syntax-e' instead of `syntax->datum'?
I would ordinarily expect something like (outer (add1 x)) to use the
outer version of `x'.
Is there a way to make (outer (outer x)) do the right thing while still
using syntax parameters?
Do you consider this behavior to be surprising? Would you expect as the
author of `m' that your macro affects the behavior of `outer'?
(define-syntax m
(syntax-rules ()
((_ val)
;; Helper function
(let ()
(def (h i) (* i val))
(h 2)))))
(def (g x)
(def (h x)
(m (outer x)))
(h 3))
-> "expand: unbound identifier in module in: x"
--
Brian Mastenbrook
brian at mastenbrook.net
http://brian.mastenbrook.net/