guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: with-syntax return error in Guile, not in Kawa or Racket


From: Damien Mattei
Subject: Re: with-syntax return error in Guile, not in Kawa or Racket
Date: Sat, 11 May 2024 01:04:49 +0200

On Sat, May 11, 2024 at 12:23 AM Jean Abou Samra <jean@abou-samra.fr> wrote:

> > it is clear that calling <- via ← give a bad result, if instead i use
> directly
> > <- code works.
>
> OK, I think I get it now:
>
> (define-syntax <-
>   (lambda (sintax)
>     (syntax-case sintax ()
>       ((<- arg)
>        (datum->syntax sintax (syntax->datum #'arg))))))
>
> ;; Works:
> (let ((foo "ABCD\n"))
>   (display (<- foo)))
>
> (define-syntax-rule (← . args) (<- . args))
>
> ;; Fails (as expected, documented and standard):
> (let ((foo "ABCD\n"))
>   (display (← foo)))
>
>
>
> Well, I was wrong that you had to go out of your way to make
> a difference between <- and ←.

thank you :-)

In fact it's a lot simpler than
> I thought, as the example above shows. But Maxime and I told
> you that this syntax->datum → process → datum->syntax dance
> was not a good idea. Now you've learnt why, the hard way :-)
>
> yes :-) it is a good lesson as we say in France

> In the datum->syntax call, if you use the macro's argument
> (which I called "sintax"), the lexical context introduced
> is wherever the macro was expanded. In the case of ←,
> that's in the body of the macro definition of ←, so variables
> from the let form where foo is bound are unavailable.
>
yes again i undestood at least this ,if #f is used there is an empty
lexical context, if it is the stx of the macro then it is the lexical
context is the one where the macro is expanded (but not runtime?) the
lexical context is local , i understand a bit more...

>
> Don't make your life complicated for no reason :-)
>

but it is not for no reason :-) :
 i had now one code (logiki) that works when i remove the "syntax->datum →
process → datum->syntax" just keep process with the cloned ← macro OR do
not clone the macro ← (2 solutions) and copy it entirely
 In this case the best solution is to get rid of "syntax->datum → process →
datum->syntax" just keep process and the simple cloned macro

but i have another code : back-propagation which no more works if i get rid
of "syntax->datum → process → datum->syntax" so tomorrow i will dig in the
back-propagation code to see why it no more works without "syntax->datum →
process → datum->syntax" i had patched this solution without well
understanding what happens

but tomorrow i do not want to make another 5.00 AM clock sleeping....
that's not good for the brain ;-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]