首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >[MSGFUN1]和[MSGPASS2]试图使用实例

[MSGFUN1]和[MSGPASS2]试图使用实例
EN

Stack Overflow用户
提问于 2016-05-05 13:44:00
回答 1查看 131关注 0票数 0

我试着在wxclips中运行类,但是它根本不起作用,问题出在哪里。注意,这段代码来自教程,它应该可以工作,但它不是

代码语言:javascript
复制
   > CLIPS> (defclass A (is-a USER)   (role concrete)  (slot foo (create-accessor write))   (slot bar)) 
   > CLIPS> (make-instance a of A (foo 36)) [a] CLIPS> (make-instance b of A (bar 45)) [MSGFUN1]
   > No applicable primary message-handlers found for put-bar. FALSE CLIPS>

> CLIPS>(defclass person (is-a USER) (multislot full-name) (role concrete) (slot gender (allowed-symbols male female)) (slot age))
> CLIPS>(definstances people (mike of person(gender "male")(age 24))) 
> CLIPS>(send [mike] get-gender)
[MSGPASS2] No such instance mike in function send
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-05 16:58:19

您需要为您想要读或写的任何槽创建槽访问器,并且在发出(重置)命令之前不会创建来自定义的实例。

代码语言:javascript
复制
CLIPS> (defclass A (is-a USER) (role concrete) (slot foo(create-accessor write)) (slot bar (create-accessor write))) 
CLIPS> (make-instance a of A (foo 36)) 
[a]
CLIPS> (make-instance b of A (bar 45)) 
[b]
CLIPS> (defclass person (is-a USER) (multislot full-name) (role concrete) (slot gender (allowed-symbols male female) (create-accessor read-write)) (slot age (create-accessor read-write)))
CLIPS> (definstances people (mike of person(gender "male")(age 24))) 
CLIPS> (reset)
CLIPS> (send [mike] get-gender)
"male"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37052264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档