From b20dfd43580bd97003521bbf046440519a0e94fc Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 11 Jun 2016 15:08:29 -0700 Subject: defsymacro must remove special marking. * eval.c (op_defsymacro): Remove sym from the special hash, unless compatibility 143 or lower is requested. * txr.1: Document effects of evaluating defsymacro if a global variable of the same name exists, and the behavior in lexical scopes where sym is bound. Added compatibility notes covering the code change. --- eval.c | 2 ++ txr.1 | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index 6246ac1a..39ee9652 100644 --- a/eval.c +++ b/eval.c @@ -1567,6 +1567,8 @@ static val op_defsymacro(val form, val env) eval_error(form, lit("let: ~s is not a bindable symbol"), sym, nao); remhash(top_vb, sym); + if (!opt_compat || opt_compat > 143) + remhash(special, sym); sethash(top_smb, sym, cons(sym, second(args))); return sym; } diff --git a/txr.1 b/txr.1 index dcfe145b..cdcc9cfe 100644 --- a/txr.1 +++ b/txr.1 @@ -25167,6 +25167,23 @@ Note: if a symbol macro expands to itself directly, expansion stops. However, if a symbol macro expands to itself through a chain of expansions, an infinite expansion time loop results. +If a global variable exists by the name +.metn sym , +then +.code defsymacro +first removes that variable from the global environment, and if that +variable is special, the symbol's special marking is removed. +.code defsymacro +doesn't alter a dynamic binding of a special variable. Any such +a binding remains intact. +If +.code defsymacro +is evaluated in a scope in which there is any lexical or dynamic binding +of +.meta sym +in the variable namespace, whether as a variable or macro, +the global symbol macro is shadowed by that binding. + .coNP Operator @ symacrolet .synb .mets (symacrolet >> ({( sym << form )}*) << body-form *) @@ -43276,7 +43293,10 @@ variable didn't include the trailing slash. The function semantics changed after version 143 to be more compatible with ANSI Common Lisp. Until 143, that function removed only the global binding, leaving the dynamic rebinding of a variable -intact. +intact. The +.code defsymacro +operator neglected to remove the symbol's special variable +mark, if the symbol was previously defined as a special variable. .IP 142 Until version 142, the \*(TX pattern language supported a prefix convention on data sources. Data sources beginning with the character -- cgit v1.2.3