Closed slozovsky closed 5 years ago
As mentioned in issue #25, it is not possible to set a default name in CLIPS 6.30 classes C API.
In clipspy 6.40 I switched the instance name to keyword a argument. It now works as expected.
In [1]: import clips
In [2]: env = clips.Environment()
In [3]: env.build('(defclass MyClass (is-a USER) (slot Slot))')
In [4]: defclass = env.find_class('MyClass')
In [5]: defclass.make_instance(Slot=1)
Out[5]: Instance: [gen1] of MyClass (Slot 1)
It looks like "gensym" is not exposed through API.
When an instance is created in CLIPS, instance name is optional.
If instance name is not supplied, CLIPS calls (gensym) and generates a name ([gen1] in the example). It would be nice to have exactly the same behavior in clipspy.
As of now:
instance = klass.new_instance('')
would create an instance with an empty name. Pyclips would generate name in such case. Another option is use None as an indicator that clipspy should call (gensym).
There are work arounds for sure - it's easy for a user to generate some symbols by himself, but that would duplicate the feature already present in CLIPS.