On Sat, Jan 7, 2012 at 1:05 AM, Andy Wingo wrote: > On Mon 05 Dec 2011 19:12, Stefan Israelsson Tampe > writes: > > > (define-syntax info > > (lambda (x) > > (syntax-case x () > > ((_ x) > > (pk (syntax-binding-info (syntax->datum #'x))) > > #'#f)))) > > I agree with Ian that we should be operating on syntax objects here, not > on datums. Also, what should the type of the return value be? Racket > implies that it should be a procedure, no? > syntax-binding-info just returns the binding information used at a lookup in psyntax for an identifier but it would be better if it returns a lookup procedure that applied to a syntax object gives the lookuped information assuming that psyntax is not mutating. using this primitive we can design a syntax-local-value according to racket e.g. (syntax-local-value id-stx [failure-thunk intdef-ctx]) -> any id-stx : syntax? failure-thunk : (or/c (-> any) #f) = #f intdef-ctx : (or/c internal-definition-context? #f) = #f This should return the value of the macro binding that can be anything and if it's not a macro eval failure thunk or return #f if not supplied. Also intef-ctx could in our case be then lookup-function returned by a call to syntax-binding-info in order to mimic the racket logic. To note is that in syntax-parse syntax classes are defined as a macro with a struct value instead of a transformer. Also to not is that in racket they have special renamer macros that interacts with this function in such a way that the syntax-local-value of a renamer macro is following the renamer and calls this function again on the renamer value automagically. It should be noted that renamer macros is needed to make syntax-parse clean in that you long descriptive names for the syntax classes and it is assumed that you rename them when using the actual syntax parse. > > and calling this in an example lead to > > (let-syntax ((a (lambda (x) #'#f))) > > (info a)) > > Does it work on toplevel macros as well? > > Yes! /Stefan