On Tue, Oct 28, 2014 at 09:31:44PM +0100, Michele La Monaca wrote: > Hi, > > shadowing a macro doesn't seem to work properly in all the cases: > > (define-syntax my-begin (syntax-rules () ((_ x ...) (begin x ...)))) > (let ((my-begin -)) (my-begin 0 1)) ; => -1 (ok) > (define my-begin -) > (apply my-begin '(0 1)) ; => -1 (ok) > (my-begin 0 1) ; => 1 (oops) > > Thus `my-begin' acts as either a procedure or a macro depending on the > context. > > Redefining `begin' (or even `##core#begin') has the same > unsatisfactory behavior: > > (let ((begin -)) (begin 0 1)) ; => -1 > (define begin -) > (apply begin '(0 1)) ; => -1 > (begin 0 1) ; => 1 > > Is this the expected behavior?
Yes, this is according to spec. Macros aren't first-class, so whenever you use the same identifier in a non-application context it will look up the identifier in the runtime environment. In application context it will check the syntactic (compile-time) environment first. I agree this is surprising as Scheme is touted to be a Lisp-1, but this is just one of those nasty dark corners of the spec. Cheers, Peter -- http://www.more-magic.net _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users