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: CL not is not not?


OK, I figured this out.

The problem line is
boolean val = PrimType.booleanValue(value);

in Compilation#compileConstant. PrimType#booleanValue is implemented as:
return ! (value instanceof Boolean) || ((Boolean) value).booleanValue();
which (of course!) returns the wrong value when passed Lisp2.FALSE
(which is a LList, not a Boolean) in Common Lisp.

Replacing that line in Compilation.java with
boolean val = getLanguage().isTrue(value);
does the right thing:

$ kawa --scheme
#|kawa:1|# (not #t)
#f
#|kawa:2|# (not #f)
#t
$ kawa --lisp
#|kawa:1|# (not t)
nil
#|kawa:2|# (not ())
t

Patch attached.


-Jamie

On Apr 24, 2012, at 4:25 AM, Per Bothner wrote:

On 04/24/2012 01:03 AM, Jamison Hope wrote:
Speaking of Common Lisp, I find this interaction to be very curious...

$ kawa --lisp
#|kawa:1|# (not t)
t

Trying with --debug-print-final-expr I see:


#|kawa:1|# (not t)
[Compiling final atInteractiveLevel$1 to atInteractiveLevel$1:
(Module/atInteractiveLevel$1/1/ () (Quote () ::boolean))]
t

So constant-folding works, correctly yielding ().
Then that gets cast to boolean.  My guess is the problem is
that cast is to the *Scheme* version of the boolean type,
so () is treated as true.

Using --debug-dump-zip shows the result is passed to writeBoolean
in the actual run method.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

-- Jamison Hope The PTR Group www.theptrgroup.com


Attachment: not-fix.patch
Description: Binary data


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