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

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to