最近我开始学习语言。在尝试“方法”消息时,我写道:
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“本身?
发布于 2015-03-26 12:32:50
根据指南的说法,method()引入一个对象来存储局部变量,并将本地的self指针设置为消息的目标。因此,没有来自目标的插槽,但我们可以通过self获得它们
Io> f := method(self getSlot("f"))
==> method(
self getSlot("f")
)
Io> f
==> method(
self getSlot("f")
)发布于 2014-02-09 10:38:45
试试g := block(getSlot("g")),它应该能做你想做的事情。不幸的是,我无法解释为什么会这样-对不起。我认为这与block和method以不同的方式设置self和proto指针有关。
您可以在method resp中尝试以下操作。block和比较结果:
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 objecthttps://stackoverflow.com/questions/21619802
复制相似问题