kawa-commonlisp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Kawa-commonlisp-dev] 'NIL != '()


From: Jamison Hope
Subject: Re: [Kawa-commonlisp-dev] 'NIL != '()
Date: Tue, 7 Aug 2012 18:15:01 -0400

On Aug 7, 2012, at 5:10 PM, Charles Turner wrote:

The following equality does not currently hold in Kawa CL

(eq 'nil '()) ;=> nil

but it should.

I'm not very confident, but I think this is because nil is looked up
in the EmptyNamespace (or current lisp package in my repository),
whereas () is processed by LispReader#makeNil, which returns
LList.Empty. Of course, the mapping in EmptyNamespace is nil =>
LList.Empty, which is confusing me, I guess you'd need a RefExp to get
the LList.Empty.

The initialisation in CommonLisp:

 public static final LList FALSE = LList.Empty;
 public static final Expression nilExpr = new QuoteExp(FALSE);

seems to point to the problem, obviously they were designed to be
different objects, which seems wrong to me, but this is code Per
wrote, so I'm not confident I understand what's happening here.

Any suggestions on how to fix this?

Those are separate objects because one is a value (one you are likely
to encounter from user code) and the other is an Expression which is
internal to the workings of the compiler. In particular, nilExpr is
not 'nil:

$ kawa --lisp
#|kawa:1|# 'nil
nil
#|kawa:2|# (static-field "gnu.commonlisp.lang.CommonLisp" "nilExpr")
(Quote
  ())

The inequality between 'nil and '() is a completely separate issue.
Note:

#|kawa:1|# ()
()
#|kawa:2|# '()
()
#|kawa:3|# nil
()
#|kawa:4|# 'nil
nil
#|kawa:5|# (eval 'nil)
()

'nil (unlike any other quoted symbol) should be self-evaluating but it isn't.

Other CL implementations probably get away with this by just using the symbol itself as the canonical representation of NIL; Kawa, however, chooses to use
LList.Empty so that Scheme lists and Lisp lists are interchangeable.

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]