guile-devel
[Top][All Lists]
Advanced

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

syntax-local-value patch for discussion


From: Stefan Israelsson Tampe
Subject: syntax-local-value patch for discussion
Date: Mon, 5 Dec 2011 19:12:28 +0100

So I tried to get hold of the macro binding. So with the following patch wich should be enogh
for me to make progress porting rackets syntax parse to guile.

Would be very glad if we could find a interface to expose this information that is sane
and rigid manner. So we should discuss this feature.

Anyway about the patch.
I added a fluid that is setted with a closure that captures enough syntax information
so that we can lookup the macro value local or global. It basically uses the same method
as psyntax macroexpander.

Now we can write,
(define-syntax info
  (lambda (x)
    (syntax-case x ()
      ((_ x)
        (pk (syntax-binding-info (syntax->datum #'x)))
        #'#f))))

and calling this in an example lead to
(let-syntax ((a (lambda (x) #'#f)))
      (info a))

;;; ((macro . #<procedure 1a68480 at ice-9/eval.scm:396:13 (a)>))

or

 (let ((a 1)) (info a))
    ((lexical . #{a 310}#))

So with this I can attach meta information to macros local or not by using a weak hash.

Anyway a hack but it shows what is needed.

Happy Hacking :-)

---------- Forwarded message ----------
From: Stefan Israelsson Tampe <address@hidden>
Date: Sun, Dec 4, 2011 at 8:22 PM
Subject: syntax-local-value
To: guile-devel <address@hidden>


In looking at racket syntax-parse there seems to be some advanced macrology
that is not included in guile.

The light now is on the possibility to attach data to macros. I figure that I could
reproduce this by using a weak hash-table but miss the functionality of

syntax-local-value

e.g.
http://docs.racket-lang.org/reference/stxtrans.html#%28def._%28%28quote._~23~25kernel%29._syntax-local-value%29%29

Basically the possibility to get the macro-object associated to a symbol in an environment if I have understyand this.

So is there a guile feature that matches this at a reasonable level?

Regards
Stefan

Attachment: boot-9-local-binding.diff
Description: Text Data

Attachment: psyntax-local-binding.diff
Description: Text Data


reply via email to

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