I start with the following code, which works as you'd expect:

#lang racket

(require syntax/parse/define)

(define-simple-macro (my-macro)
  (display a_definition))

(define a_definition "some string")
(my-macro)

(It displays the text "some string")

Then tried defining a_definition and calling the macro again, but inside of 
let:

(require syntax/parse/define)

(define-simple-macro (my-macro)
  (display a_definition))

(let ()
  (define a_definition "some string")
  (my-macro))

This time I get an error:

a_definition: unbound identifier
  context...:
  other binding...:
  common scopes...: in: a_definition

!! This perplexes me, as from my (very limited) understanding, the above 
code should just macrologically expand into something akin to:

(let ()
  (define a_definition "some string")
  (display a_definition))

Which is what appears to be happening when I do the same thing in the 
global space. I really want to be able to define something within a code 
block and have access to that definition via macros called in that same 
code block. What is recommended?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/bb0ea585-0fe4-41bb-a639-af13143b61bb%40googlegroups.com.

Reply via email to