This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: conditional bindings




On 12/11/2014 02:43 PM, Jamison Hope wrote:
It just seems strange that the caller's environment affects whether the
invokation matches a pattern with a literal.  I have trouble seeing how

(let ((else #f)) (cond (#f (display "a\n")) (else (display "b\n"))))
=> #!void

is hygienic, but

(defmacro add (x y) `(+ ,x ,y))
(let ((+ -)) (add 1 2))
=> -1

is unhygienic.  In both cases, the behavior of the macro depends upon
the *caller* environment and not just the lexical environment of the
macro definition.

The former is hygienic because 'else' is both bound and referenced
in the application site; thus the reference matches the binding.
I.e. the else reference in the cond use is in the lexical scope
of the else definition that in scope in the cond application.

The add is unhygienic because '+ is referenced in the macro definition
and bound in the scope of the macro application.  I.e. the '+ in the add
definition is not in the lexical scope of the '+ in the macro application.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]