[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: |
Jean Abou Samra |
Subject: |
Re: with-syntax return error in Guile, not in Kawa or Racket |
Date: |
Sat, 11 May 2024 00:23:29 +0200 |
User-agent: |
Evolution 3.52.1 (3.52.1-1.fc40) |
> 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 ←. 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 :-)
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.
Don't make your life complicated for no reason :-)
signature.asc
Description: This is a digitally signed message part
- Re: with-syntax return error in Guile, not in Kawa or Racket, (continued)
- Re: with-syntax return error in Guile, not in Kawa or Racket, Jean Abou Samra, 2024/05/09
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/10
- Re: with-syntax return error in Guile, not in Kawa or Racket, Jean Abou Samra, 2024/05/10
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/10
- Re: with-syntax return error in Guile, not in Kawa or Racket, Jean Abou Samra, 2024/05/10
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/10
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/11
- Re: with-syntax return error in Guile, not in Kawa or Racket, Jean Abou Samra, 2024/05/11
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/12
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/10
- Re: with-syntax return error in Guile, not in Kawa or Racket,
Jean Abou Samra <=
- Re: with-syntax return error in Guile, not in Kawa or Racket, Damien Mattei, 2024/05/10
- Macros that don't work, Keith Wright, 2024/05/15