soegaard2
2020-12-31 11:26:05

@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.


soegaard2
2020-12-31 11:49:29

@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.


anything
2020-12-31 21:45:38

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.


anything
2020-12-31 21:54:04

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.


soegaard2
2020-12-31 21:55:01

Exactly.


anything
2021-1-1 06:40:47

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.)

Source: http://rmculpepper.github.io/malr/basic.html