Fact and Instance addresses should be converted
Brought to you by:
franzg
Functions in CLIPS could return FACT-ADDRESS and INSTANCE-ADDRESS values (or multifields thereof). When this happens, the values should be converted to Fact and Instance objects respectively instead of raising an exception. In the same way, when a Fact object or an Instance object is passed to the CLIPS subsystem, it should be converted to a FACT-ADDRESS or INSTANCE-ADDRESS respectively.
Logged In: YES
user_id=328337
Originator: YES
It can be done, but it will anyway be impossible to pass a FACT-ADDRESS or an INSTANCE-ADDRESS to a CLIPS function, because the underlying CLIPS API (that is, the FunctionCall() function) does not accept non-constant arguments, which must be passed as a space-delimited string [see Clips APG, "4.1.10 FunctionCall", page 47].
Logged In: YES
user_id=328337
Originator: YES
It can be trickier than what I thought: actually I wrote the previous comment after experimenting a little (I managed to assign a FACT-ADDRESS value to a defglobal from PyCLIPS). But there is a problem: while returning FACT-ADDRESSes and INSTANCE-ADDRESSes from CLIPS (to C or whatever) is directly supported, the API to pass values to CLIPS does not support passing other than basic types and EXTERNAL-ADDRESSes (converting arguments involves using DATA_OBJECT structures and the AddXXX macros, which in my tests I "bypassed").
Logged In: YES
user_id=328337
Originator: YES
The fixes for this bug or request have been accepted and
committed to current CVS tree: next release will include these
fixes, possibly among other enhancements.
Logged In: YES
user_id=328337
Originator: YES
I have submitted a version that should work to the SVN repository. It still has to be tested thoroughly, and specific tests for the new functionality have to be written.
Logged In: YES
user_id=328337
Originator: YES
Implemented in PyCLIPS 1.0.6
Logged In: YES
user_id=328337
Originator: YES
It can be trickier than what I thought: actually I wrote the previous comment after experimenting a little (I managed to assign a FACT-ADDRESS value to a defglobal from PyCLIPS). But there is a problem: while returning FACT-ADDRESSes and INSTANCE-ADDRESSes from CLIPS (to C or whatever) is directly supported, the API to pass values to CLIPS does not support passing other than basic types and EXTERNAL-ADDRESSes (converting arguments involves using DATA_OBJECT structures and the AddXXX macros, which in my tests I "bypassed").