On Tue, Oct 28, 2014 at 11:02:40PM +0100, Michele La Monaca wrote: > On Tue, Oct 28, 2014 at 9:35 PM, Peter Bex <peter....@xs4all.nl> wrote: > > 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. > > If so, why > > (let ((begin -)) (begin 0 1)) > > returns -1?
Because identifiers introduced through lexical scoping work differently from identifiers introduced at top level. It has been pointed out before that "the toplevel is hopeless", but the way CHICKEN deals with it is much more like a Lisp-2 than many other Schemes. This inconsistency could be considered a bug: if a new identifier is introduced at the toplevel which "shadows" a macro, it could erase the macro. It's not a priority because the spec doesn't really say what to do, and the responses of various Schemes differ in this. Gambit for example even disallows redefining macro definitions: > (define begin -) *** ERROR IN (console)@1.9 -- Macro name can't be used as a variable: begin But yeah, many other Schemes simply replace the macro definition by the procedure. Changing this would be an invasive change that overhauls the entire system. I don't mind doing this, but there are a few odds and ends that need fixing first, before this is feasible. I've created ticket #1166 to track this, but don't expect any progress on this for at least a year. Cheers, Peter -- http://www.more-magic.net _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users