This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: conditional bindings
- From: Per Bothner <per at bothner dot com>
- To: kawa at sourceware dot org
- Date: Thu, 11 Dec 2014 15:16:31 -0800
- Subject: Re: conditional bindings
- Authentication-results: sourceware.org; auth=none
- References: <54868D3A dot 10605 at bothner dot com> <8FDA27DC-2AC0-442E-879B-390760EAC000 at theptrgroup dot com> <5487BD04 dot 4080709 at bothner dot com> <1A9D21C9-3897-47BD-AB86-60D249A9CB8D at theptrgroup dot com> <54891FCF dot 2000608 at bothner dot com> <0890BFFE-8180-4F6D-9F1A-9E93F0E9C9BA at theptrgroup dot com> <5489E441 dot 3030502 at bothner dot com> <E8E1CF30-33BD-4BFE-9412-176558B932E5 at theptrgroup dot com>
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/