[plt-scheme] Defining syntax parameters that act like ordinary symbols outside of syntax-parameterize
Hi,
I'll respond to Ryan, Matthias and Robby here.
First, I'll clarify what I wanted to achieve and in what context.
I'm using the macro alambda, given below.
(define-syntax-parameter self
...) ;;To be filled in later
(define-syntax alambda
(syntax-rules ()
[(alambda args body ...)
(letrec [(me (lambda args
(syntax-parameterize [(self (make-rename-transformer #'me))]
body ...)))]
me)]))
The question here is what self should be defined to.
Both Ryan and Matthias (I apologize in advance if I misrepresent your position) appear to argue that
self should be defined to raise a syntax error by default, unless within a syntax-parameterize as in the
expansion of alambda.
This is a reasonable point of view if self is to be considered an integral part of alambda's syntax, that is,
a keyword that has a well-defined meaning only in alambda expressions.
However, I see the role of alambda as binding the ordinary identifier self using letrec.
That is, I view self as just another identifier, that just happens to implicitly receive a certain value in alambda expressions.
To me, (let ((self 10)) self) should evaluate to 10, without raising a syntax error.
More generally, self should be free for any use at phase level 0.
What I meant by "cluttering up the namespace" in my first message was "making a symbol unavailable for any uses outside of specific expressions".
My attempt to alpha-rename self to a gensym was intended to redirect any non-alambda references to self to a specific symbol, which could then be bound
as required by any programmer who wished to do so.
As Matthias correctly remarked, this gensym is unbound by default in phase 0.
Robby's suggestion seems to avoid that problem and looks like a reasonable compromise, if I understood it correctly.
-Remco