首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iolanguage getSlot不返回预期的对象

iolanguage getSlot不返回预期的对象
EN

Stack Overflow用户
提问于 2014-02-07 05:08:38
回答 2查看 140关注 0票数 2

最近我开始学习语言。在尝试“方法”消息时,我写道:

代码语言:javascript
复制
Io> f := method(getSlot("f"))
==> method(
    getSlot("f")
)

Io> slotSummary
==>  Object_0x97f41a8:
  Lobby            = Object_0x97f41a8
  Protos           = Object_0x97f4090
  _                = nil
  exit             = method(...)
  f                = method(...)
  forward          = method(...)
  set_             = method(...)

Io> f
==> nil

但是为什么调用f将返回零而不是"f“本身?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-26 12:32:50

根据指南的说法,method()引入一个对象来存储局部变量,并将本地的self指针设置为消息的目标。因此,没有来自目标的插槽,但我们可以通过self获得它们

代码语言:javascript
复制
Io> f := method(self getSlot("f"))
==> method(
    self getSlot("f")
)
Io> f
==> method(
    self getSlot("f")
)
票数 2
EN

Stack Overflow用户

发布于 2014-02-09 10:38:45

试试g := block(getSlot("g")),它应该能做你想做的事情。不幸的是,我无法解释为什么会这样-对不起。我认为这与blockmethod以不同的方式设置selfproto指针有关。

您可以在method resp中尝试以下操作。block和比较结果:

代码语言:javascript
复制
call sender          #locals object of caller
call message         #message used to call this method/block
call activated       #the activated method/block
call slotContext     #context in which slot was found
call target          #current object
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21619802

复制
相关文章

相似问题

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