[self-interest] Creating objects from the shell
ardeujho at cd.pn
Sat Mar 15 08:22:12 UTC 2014
On Sat, Mar 15, 2014, at 05:36 AM, Stephen De Gabrielle wrote:
1. defining a method object doesn't seem to run it's code? (I don't get
'test' returned). Instead if I do 'lobby person5'.
- Am I right that method objects only 'run' when called, and their
slots only exist for the duration of their action?
Yes, that's right. Your method, person3, is created and added as a
slot. It is called when you do "lobby person3". That method has local
variables age, name and parent.
2. method objects don't get an outliner - because they only exist as
objects while they are running.
Right. You can get an object representing the method using mirrors:
(reflect: lobby') at: 'person3'
Browse through the methods on that in an outliner.
This seems to indicate I can't create an object that can do some setup
code when it is created? Am I missing a trick?
This is often done with a variant of 'copy'. Eg. on an object you'd do:
myobject copyWithSomeEffect: 'blah'.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Self-interest