Populating INSTANCE-ADDRESS slot in embedded CLIPS

58 views
Skip to first unread message

mgvirtzm

unread,
Jun 28, 2011, 7:49:16 AM6/28/11
to CLIPSESG
I would prefer to populate an INSTANCE-ADDRESS slot using MakeInstance
as follows:

(<slot-name> <Instance-<instance-name>>).

However, in this form it leads to unexpected problems later on - looks
like memory corruption, for example GetInstanceClass function returns
pointer containing 1.

I succeed when populating instance address in two stages:

1) Populate instance name: (<slot-name> [<instance-name>]) during
MakeInstance
2) Issue DirectPutSlot with INSTANCE_ADDRESS type.

Problem is that agenda is refreshed on every command (MakeInstance and
every DirectPutSlot), instead of once per MakeInstance. This impacts
performance.

What can be done to create instances with instance addresses causing
single agenda refresh?

In non-embedded CLIPS, it is possible to use progn function to perform
multiple actions with single refresh. This function seems not to be
available in embedded CLIPS.

Thank you in advance,
Michael.

CLIPS Support

unread,
Jul 5, 2011, 2:06:11 PM7/5/11
to CLIPSESG
Try embedding the instance-address function call within your make-
instance string:

(<slot-name> (instance-address <instance-name>))

mgvirtzm

unread,
Jul 10, 2011, 8:12:33 AM7/10/11
to CLIPSESG
Hi, this is the first thing I tried - but MakeInstance function allows
only constants as slot value.

However, I found another solution that seems working - overriding
default put-<slot> method for each instance address slot, as follows:

1) add (override-message special-put-<slot>) facet

2) add message handler:

(defmessage-handler <class> special-put-<slot> primary (?addr)
(bind ?self:<slot> (instance-address ?addr)))

It seems that in this case agenda is refreshed once per MakeInstance.

With best regards,
Michael.
Reply all
Reply to author
Forward
0 new messages