Stefan Israelsson Tampe <stefan.ita...@gmail.com> writes: > 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. As it stands, I agree it is pretty simplistic, but I'm not sure what to propose :) What is the intended use cases for this? A compile-time values mechanism?
> 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. The patch looks fine to me, although I admit I have little experience with psyntax. > > Now we can write, > (define-syntax info > (lambda (x) > (syntax-case x () > ((_ x) > (pk (syntax-binding-info (syntax->datum #'x))) > #'#f)))) FWIW, I wouldn't expect to have to pass a raw datum to any procedure with a syntax prefix. If we keep this procedure, I think the syntax->datum should be hid, or the procedure renamed. > So with this I can attach meta information to macros local or not by > using a weak hash. I have 'define-type' & 'type-case' macros, basically copied from racket's plai language[0][1] , that suffers from a complete lack of error handling in the case where the type-id is not, in fact, a type-id. If I were to use this mechanism, I would create a weak hash of datatype-ids, adding them to the hash with 'define-type', and checking if they are in the hash in my 'type-case' macro. Would that be right? 0. http://docs.racket-lang.org/plai/plai-scheme.html 1. I can post these if people want them -- Ian Price "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"