#6 An easy way to access a Fact Relation

closed
6
2004-08-17
2004-08-16
Francesco Garosi
No

PyCLIPS provides the API-like methods to retrieve Fact
slots, either declared or implied: however there is no
way to quickly access a Fact relation (the first field in a
CLIPS fact), the only way to do it is to apply a formula
like

f = <somefact>
rel = f.CleanPPForm()[1:-1].split()[0]

which always succeeds for correctly defined facts but
makes code much less readable. Probably this formula
should be implemented at the higher level in order to
improve readability in an operation that is likely to be
performed several times.

The proposal is to implement a read-only property
called 'Relation' for Fact objects, which actually returns
the string defined above as a Symbol (which is the type
of the "relation" as in BPG, page 11). The property
should be read-only because this symbol either depends
on a specific Template or it occurs in an already
asserted Fact: in both cases it would be not modifiable.

Discussion

    • status: open --> closed
     
  • Logged In: YES
    user_id=328337

    Closed with release 1.0_03.