Reputation: 11
can I use variable as a name of instance? Example:
(make-instance [?input] (name)(age))
Upvotes: 1
Views: 175
Reputation: 10757
The name slot of an instance is predefined and stores the instance name, so when creating an instance you wouldn't specify it twice using the make-instance function. Otherwise, here's the syntax for using a variable to specify an instance name:
CLIPS (6.31 6/12/19)
CLIPS>
(defclass PERSON
(is-a USER)
(slot full-name)
(slot age))
CLIPS> (bind ?input p1)
p1
CLIPS>
(make-instance ?input of PERSON
(full-name "John Doe")
(age 23))
[p1]
CLIPS> (send [p1] print)
[p1] of PERSON
(full-name "John Doe")
(age 23)
CLIPS>
Upvotes: 1