clips

Comprehensive overview of all keywords/reserved names in CLIPS


I have been studying the CLIPS Reference Manual and was trying to understand which keywords/names are reserved in which context. Initially this started with the intent of figuring out which names are reserved in addition to the functions listed in the Appendix H: Reserved Function Names.

As far as I understand the following rules apply:

  1. test, and, or, not, declare, logical, object, exists, and forall are illegal as the first field of any fact; otherwise, they are legal, albeit discouraged.
  2. name and is-a cannot be names of slots according to section 9.3.3 but seem to be legal names otherwise. The examples from the CLIPS repository however contradict this as I've seen a (slot name) in them. What is the intended design here?

I'd like to know whether there are more rules which I've missed or whether it can be said that all other names (maybe even names like deffacts) are legal outside of their actual uses.


Solution

  • Most names are legal outside of the context where they have special meaning. So the symbols is-a and name cannot be used as slot names for the defclass construct (where they are used to support inheritance and message passing), but they can be used as slot names for the deftemplate construct (which predated the defclass construct).

    For example, this is all legal:

             CLIPS (6.4.1 4/8/23)
    CLIPS> 
    (defrule defclass
       (deftemplate)
       (is-a)
       (name)
       (declare)
       (+ 3 4)
       (slot)
       =>)
    CLIPS> (assert (deftemplate) (is-a) (name) (declare) (+ 3 4) (slot))
    <Fact-6>
    CLIPS> (facts)
    f-1     (deftemplate)
    f-2     (is-a)
    f-3     (name)
    f-4     (declare)
    f-5     (+ 3 4)
    f-6     (slot)
    For a total of 6 facts.
    CLIPS> (agenda)
    0      defclass: f-1,f-2,f-3,f-4,f-5,f-6
    For a total of 1 activation.
    CLIPS>