Say I have a class PERSON with a slot 'sex'.
I also have a class MAN which is a sub class of PERSON.
In the definition of MAN, how do I set the value of 'sex' to 'male'.
I know this must be simple but I am not able to get it right.
(slot sex (default male)))
CLIPS> (make-instance of PERSON)
CLIPS> (send [gen1] print)
[gen1] of PERSON
CLIPS> (make-instance of MAN)
CLIPS> (send [gen2] print)
[gen2] of MAN
Thanks Gary. I don't mean to be picky, but is there a way to do this without redefining the slot in the subclass? I am not saying that is a bad approach but it seems to me there must be a way to do it without redefining.
In other langauages (as you know) you would set the value in a constructor.
(defmessage-handler MAN init after ()
(send ?self put-sex male))
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.