I think Steve Solomon wrote:
> This is a minor complaint. Why can't one use nil to match an empty list?

Short answer: because Jess inherited its basic rule language semantics
from CLIPS, and that's how it works in CLIPS.

> Only the pattern (sprocket ?id) matches (sprocket 2) with no following
> symbols. I would have thought that (sprocket ?id nil) at least would
> also work, i.e. nil matching the empty list, especially considering that
> ~~nil matches a non-null symbol. Perhaps my concept of nil is influenced
> too much by Lisp.

Yes, that's pretty much it. Jess's 'nil' is more like Java's
'null'. In Lisp, 'nil' means an empty list, while in Java, 'null'
means "no list at all," whereas an empty List is a List object with no
contents. In Lisp, there's no difference between these two ideas, but
there definitely is in Java and in Jess. Whereas in Lisp 'nil' means
'no value', in Java 'null' is a definite specific value; Jess is the
same way. 

Instead of using nil to match "nothing" in a list, you use
"multifields", basically variables that start with "$?", to match
"nothing or something." The patterns

(sprocket ?id $?)
(sprocket 2 $?)
(sprocket $?)

all match both (sprocket 2) and (sprocket 2 3 4).



---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to