@anything Thanks for the feedback.
I agre that the sentence on page 2 needs to improve. How about:
The form `syntax` constructs a new syntax object from a given template.
It takes the template and replaces identifiers that are bound as
pattern variables with the corresponding values.
@anything Sorry - I forgot about that subtle difference between expand
and expand-syntax
.
The function expand
“enriches” (syntactical context) the syntax object before expansion. And expand-syntax
doesn’t. The solution is this:
(define after (expand-syntax (namespace-syntax-introduce before ns)))
I’ll rewrite the exercise, either to include that information - or perhaps just use regular expand.
That looks good. I’m not sure if the preposition “as” is properly used with “bound”. I’d believe that identifiers are bound [to] pattern variables. (Also, perhaps replacing them with [their] corresponding values would be a better choice of pronoun.) Either way, though, the sentence reads very well now.
Thanks! That works and perhaps I understand the problem now. The expansion done by expand-syntax
was not finding begin
. That’s because begin did not exist in before
. (Worse still, not even #%app
was present. It’s kinda cool and an interesting that the error message is telling me even further problems I’d encounter. Pretty good friend.) The call to namespace-syntax-introduce
enriched before
with everything that was defined in ns
, which made the code fully well-defined.
Exactly.
Exercise 4: Write a macro forever
that takes an expression and evaluates it repeatedly in a loop. My solution: (define-syntax-rule (forever expr)
(let loop ()
expr
(loop)))
This seems to work, but I don’t get what the exercise is trying to show me. (Maybe I’ll see it down the road.)