(make-record-accessor-aliases gamma) (define o (make-gamma 1 2))
which evaluates with no errors, but then:
(gamma-a o)
raises a "gamma-a unbound identifier" error. I do not understand the difference between the two cases; I tried to structure the second case as the INCLUDE syntax example[1] in the R6RS document, but I cannot spot the difference.
it does not work, because both are defined while computing the expansion of the SYNTAX-RULES, and no more while computing the expansion of A, which is the one that needs it.
The following program, which only make use of A with GAMMA hard-coded, works perfectly, showing that using the identifier of the A macro use is correct:
> it does not work, because both are defined while computing the > expansion of the SYNTAX-RULES, and no more while computing the > expansion of A, which is the one that needs it.
On Sep 13, 9:43 am, marcomaggi <mrc....@gmail.com> wrote:
> Thanks, I understand why your revision works. I still do not get why > mine does not...
Because you introduced the definitions where (A) was 'typed'. (A) does not exist outside the macro in your first example. In your second example it works, because (A) is defined where you 'need' it.
On Sep 13, 11:36 am, leppie <xacc....@gmail.com> wrote:
> On Sep 13, 9:43 am, marcomaggi <mrc....@gmail.com> wrote:
> > Thanks, I understand why your revision works. I still do not get why > > mine does not...
> Because you introduced the definitions where (A) was 'typed'. (A) does > not exist outside the macro in your first example. In your second > example it works, because (A) is defined where you 'need' it.
> Cheers
> leppie
You have to be right, because your code works and mine does not! :-)
I have to partially retract my claim of understanding because of the following. Everything below is tested with Ikarus.
CASE 1: This is a short version which, according to my understanding, is equivalent to my original code:
IMO it should work because the macro use "(a 123)" expands to a LET- SYNTAX form defining a new macro, which is immediately expanded by the use "(b)"; the use "(b)" happens in the same context of the use "(a 123)". But my opinion is wrong, because I get the "unbound identifier num" error.
On Sep 13, 2:41 pm, leppie <xacc....@gmail.com> wrote:
> On Sep 13, 1:47 pm, marcomaggi <mrc....@gmail.com> wrote:
> > I get the "unbound identifier num" error for no reason I can figure > > out.
> I think that is because syntax-rules ignores the first argument (iow > it is automatically replaced with _).
> Cheers
> leppie
That's what it is! I found it in R6RS[1] in the description of SYNTAX- RULES:
"While the first subform of <srpattern> may be an identifier, the identifier is not involved in the matching and is not considered a pattern variable or literal identifier."
if the same behaviour is adopted for SYNTAX-CASE patterns, it explains also why my first revision of the code is not working: I was relying on the K in:
(syntax-case stx () ((k) ---))
to carry context informations. But I do not see any note in R6RS saying that the first subpattern in a SYNTAX-CASE pattern obeys this rule. Does it?
> On Sep 13, 2:41 pm, leppie <xacc....@gmail.com> wrote:
> > On Sep 13, 1:47 pm, marcomaggi <mrc....@gmail.com> wrote:
> > > I get the "unbound identifier num" error for no reason I can figure > > > out.
> > I think that is because syntax-rules ignores the first argument (iow > > it is automatically replaced with _).
> > Cheers
> > leppie
> That's what it is! I found it in R6RS[1] in the description of SYNTAX- > RULES:
> "While the first subform of <srpattern> may be an identifier, the > identifier is not involved in the matching and is not considered a > pattern variable or literal identifier."
> if the same behaviour is adopted for SYNTAX-CASE patterns, it explains > also why my first revision of the code is not working: I was relying > on the K in:
> (syntax-case stx () > ((k) ---))
> to carry context informations. But I do not see any note in R6RS > saying that the first subpattern in a SYNTAX-CASE pattern obeys this > rule. Does it?
No. The hygiene information in the keyword might be useful in syntax- case. You can also use it to self-recurse even in a `let-syntax' bound form.