Creating objects from the shell
Stephen De Gabrielle
spdegabrielle at gmail.com
Sat Mar 15 09:09:25 UTC 2014
Thanks. Much appreciated.
On Saturday, 15 March 2014, ardeujho <ardeujho at cd.pn> wrote:
>
>
>
>
>
> 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'.
>
>
>
>
>
>
>
--
Sent from Gmail Mobile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.selflanguage.org/pipermail/self-interest/attachments/20140315/29e1e058/attachment.html>
More information about the Self-interest
mailing list