从Scheme中的定义类型对象中提取字段
我正在尝试从以下对象中提取字段“name”或“named-expr”:(
bind 'x (num 5)) ;;请注意,这不是一个列表,而是一个类型 Binding
,其 Binding 定义为:
(define-type Binding (bind (name symbol?) (named-expr WAE?)))
我已经尝试过,但收到错误“在定义之前引用标识符:绑定名称。”这是我尝试输入的内容:
(begin (Binding-name (bind 'x (num 5)))) (begin (define x (bind 'x (num 5))) (绑定名称 x))
谢谢!
I am trying to extract the field 'name' or 'named-expr' from the following object:
(bind 'x (num 5)) ;; note that this is not a list, but a type Binding
With the Binding definition:
(define-type Binding
(bind (name symbol?) (named-expr WAE?)))
I have tried, but received the error "reference to an identifier before its definition: Binding-name." Here is what I tried typing:
(begin (Binding-name (bind 'x (num 5))))
(begin (define x (bind 'x (num 5))) (Binding-name x))
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我刚刚弄清楚了这一点,我必须在绑定类型中使用名称“bind”。
这项工作:
(开始(绑定名称(绑定'x(num 5))))
So I just figured this out, I had to use the name 'bind' within the Binding type.
This work:
(begin (bind-name (bind 'x (num 5))))