Hi,
I'm sorry if this is a basic question; I've looked through the
documentation and searched the mailing list archives and haven't found
an answer.
I have a deftemplate that has a slot with a default value. I want to
create a new deftemplate that extends the first one, but overrides the
default value. Here's a simple example:
--------------------------------
(deftemplate bird
"bird info"
(slot can-fly (default yes)) // most birds can fly
(slot name))
(deftemplate sparrow extends bird
"sparrow is a type of bird") // typical bird
(deftemplate penguin extends bird
"penguin is a type of (flightless) bird"
(slot can-fly (default no))) // this bird can't fly
(defrule I-can-fly
(bird (name ?n) (can-fly yes))
=>
(printout t ?n " can fly" crlf))
(defrule I-cannot-fly
(bird (name ?n) (can-fly no))
=>
(printout t ?n " can't fly" crlf))
(reset)
(assert (sparrow (name Hoppy)))
(assert (penguin (name Tux)))
(run)
Jess, the Rule Engine for the Java Platform
Copyright (C) 2008 Sandia Corporation
Jess Version 7.1 7/8/2008
Tux can't fly
Hoppy can't fly
--------------------------------
I'd like to be able to assert penguin facts without explicitly having
to say they can't fly every time; but I would like it to inherit other
bird slots. I suppose I could write a high salience rule to check for
penguins and fix the slot, but that doesn't seem very elegant.
Also, I'm not sure why the sparrow can't fly here. Is the original
deftemplate somehow being changed? Is there a different way to do
this? Am I doing something dumb and not noticing it? Thanks very
much.
- Bob Gaimari
--------------------------------------------------------------------
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]
--------------------------------------------------------------------