JESS: Redefining default values in deftemplates

View: New views
2 Messages — Rating Filter:   Alert me  

JESS: Redefining default values in deftemplates

by Henrique Lopes Cardoso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Is there a way to change a default value in a deftemplate?
Declaring a deftemplate twice for the same deftemplate name issues an
error (strangely, unless you define the deftemplate exactly as before).

I managed to do the following work arround:

;---
(deffunction f () return 0 )

(deftemplate t (slot s (default-dynamic (f))) )

(assert (t))

(deffunction f () return 1 )

(assert (t))

(facts)
;---

Redefining a function seems to work ok (although the Jess editor issues
a warning message). In this case, I get two facts, one with each
intended default value.

Is there a simpler way of doing this, e.g. by changing the deftemplate
directly?

Thanks.

Henrique



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: Redefining default values in deftemplates

by Wolfgang Laun-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Aug 3, 2009 at 5:48 PM, Henrique Lopes Cardoso <hlc@...> wrote:


Is there a simpler way of doing this, e.g. by changing the deftemplate
directly?

Not yet, but asking Ernest to add a Deftemplate.setSlotDefault( Value default ) might simplify it cosiderably ;-)
-W