Marc:
Can you explain what's going on here? I would expect both expressions to print the same.
Brad
[Bradley-Luciers-MacBook-Pro:~] lucier% gsi cond-test.scm a #!void [Bradley-Luciers-MacBook-Pro:~] lucier% cat cond-test.scm (pretty-print (let ((else #f)) (cond (else 'a)))) (pretty-print (cond (#f 'a))) [Bradley-Luciers-MacBook-Pro:~] lucier% gsi -v v4.6.0 20100716125419 i386-apple-darwin10.4.0 "./configure CC=/pkgs/gcc-4.5.1/bin/gcc -fschedule-insns -march=native --enable-single-host --enable-multiple-versions --enable-shared"
Afficher les réponses par date
It is because "else" is a special keyword that is searched at the head of a clause. Rebinding "else" will not change the search. Should it?
I checked and Bigloo and Chicken behave the same as Gambit, but MzScheme doesn't.
Marc
On 2010-10-15, at 4:00 PM, Bradley Lucier wrote:
Marc:
Can you explain what's going on here? I would expect both expressions to print the same.
Brad
[Bradley-Luciers-MacBook-Pro:~] lucier% gsi cond-test.scm a #!void [Bradley-Luciers-MacBook-Pro:~] lucier% cat cond-test.scm (pretty-print (let ((else #f)) (cond (else 'a)))) (pretty-print (cond (#f 'a))) [Bradley-Luciers-MacBook-Pro:~] lucier% gsi -v v4.6.0 20100716125419 i386-apple-darwin10.4.0 "./configure CC=/pkgs/gcc-4.5.1/bin/gcc -fschedule-insns -march=native --enable-single-host --enable-multiple-versions --enable-shared"
On Fri, Oct 15, 2010 at 4:17 PM, Marc Feeley feeley@iro.umontreal.ca wrote:
It is because "else" is a special keyword that is searched at the head of a clause. Rebinding "else" will not change the search. Should it?
According to r5rs macro semantics, yes.
Section 4.3.2 says:
"A subform in the input matches a literal identifier if and only if it is an identifier and either both its occurrence in the macro expression and its occurrence in the macro definition have the same lexical binding, or the two identifiers are equal and both have no lexical binding."
There's also an example in that section about how rebinding the identifier `=>' influences the behavior of 'cond' under the new binding.
--Jeff
Marc Feeley <feeley <at> iro.umontreal.ca> writes:
It is because "else" is a special keyword that is searched at the head of a
clause. Rebinding "else" will not
change the search. Should it?
I checked and Bigloo and Chicken behave the same as Gambit, but MzScheme doesn't.
What chicken version did you try?
cheers, felix
I had checked with 4.1.0 but I now built 4.6.0 and get the same behavior as 4.1.0:
% ./csi
CHICKEN (c)2008-2010 The Chicken Team (c)2000-2007 Felix L. Winkelmann Version 4.6.0 macosx-unix-gnu-x86 [ manyargs dload ptables ] compiled 2010-10-13 on macro.local (Darwin)
#;1> (define else #f) #;2> (cond (else 123)) 123 #;3> ^D % mzscheme Welcome to MzScheme v4.2 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.
(define else #f) (cond (else 123)) ^D
%
Marc
On 2010-10-18, at 5:41 AM, felix winkelmann wrote:
Marc Feeley <feeley <at> iro.umontreal.ca> writes:
It is because "else" is a special keyword that is searched at the head of a
clause. Rebinding "else" will not
change the search. Should it?
I checked and Bigloo and Chicken behave the same as Gambit, but MzScheme doesn't.
What chicken version did you try?
cheers, felix
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
From: Marc Feeley feeley@iro.umontreal.ca Subject: Re: [gambit-list] Confused Date: Sun, 24 Oct 2010 08:37:27 -0400
I had checked with 4.1.0 but I now built 4.6.0 and get the same behavior as 4.1.0:
% ./csi
CHICKEN (c)2008-2010 The Chicken Team (c)2000-2007 Felix L. Winkelmann Version 4.6.0 macosx-unix-gnu-x86 [ manyargs dload ptables ] compiled 2010-10-13 on macro.local (Darwin)
#;1> (define else #f) #;2> (cond (else 123)) 123 #;3> ^D % mzscheme Welcome to MzScheme v4.2 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.
(define else #f) (cond (else 123)) ^D
Chicken treats assignment and lexical binding differently in this context (and I'm not completely sure if R5RS requires this behaviour). The example posted originally should be handled hygienically in chicken, in any case.
cheers, felix