You might read http://www.jessrules.com/jesswiki/view?FactsAsSlotValueswhich
discusses
this topic, although the instances are facts. But you can use Java objects
just as well.
I'm not aware of a (make-instance) function in Jess. The standard approach
is
to use (new ...) or a call to some factory method as a slot value, but it's
also
possible to bind a pojo to a variable and use the variable.
(deftemplate S (slot str))
(deftemplate B (slot buf))
(deffacts strings
(S (str (Integer.toHexString 48879)))
(S (str "bar"))
(B (buf (new StringBuffer))))
(reset)
(defrule coll
?s <- (S (str ?str))
(B (buf ?buf))
=>
(?buf append ?str)
(retract ?s)
)
(defrule show
(B (buf ?buf))
(not (S))
=>
(printout t (?buf toString) crlf)
)
(run)
-W
On Fri, Apr 17, 2009 at 10:28 PM, newb1 <[email protected]> wrote:
>
> hi all,
>
> i am quite new to jess and i have some knowledge problems regarding the use
> of an instance as a slot value. is that even possible? if yes.. i have an
> example
>
> (make-instance of P(name "John")(age 30))
>
> so, here i am making an instance of a class P right? how can i put the
> created instance as a slot value? o:
>
> i am grateful for any help,
> thanks in advance
>
> --
> View this message in context:
> http://www.nabble.com/using-an-instance-as-slot-value-tp23105386p23105386.html
> Sent from the Jess mailing list archive at Nabble.com.
>
>
>
> --------------------------------------------------------------------
> 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].
> --------------------------------------------------------------------
>
>