[self-interest] Creating objects from the shell
Stephen De Gabrielle
spdegabrielle at gmail.com
Fri Mar 14 16:36:10 UTC 2014
lobby _AddSlotsIfAbsent: ( | person = ( | name. age. test = ( 'test' printLine
) | ) | )
I am sending the lobby object a message to add a new slot called person,
and in that slot put an object '( | name. age. test = ( 'test' printLine )
| ) ' which consists of three different slots; name, age and test. the test
slot contains a method that prints 'test'.
I tried the following in the terminal and in the shell
> "Self 1" lobby _AddSlotsIfAbsent: ( | person3 = ( | parent* = traits
> clonable . name . age | 'test' printLine ) | )
> "Self 1"
I'm trying to make a method object and it seems to succeed,am I right about
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?
2. method objects don't get an outliner - because they only exist as
objects while they are running.
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?
Thanks for your help.
Stephen De Gabrielle
stephen.degabrielle at acm.org
Telephone +44 (0)20 85670911
Mobile +44 (0)79 85189045
On Fri, Mar 14, 2014 at 12:02 AM, Jecel Assumpcao Jr.
<jecel at merlintec.com>wrote:
> > I've had some success creating objects from Morphic and using the
> > outliner, but I can't seem to create objects using the shell.
> > I have tried typing in some of the early examples in the handbook,
> > but I only get errors.
> > Person = (|name. age | 'test' printLn )
> > Example from handbook
> > ( | slot1. slot2 | ?here is some code? printLine )
> That is an example of a method, not a normal object. A normal object
> would look like:
> ( | slot1. slot2 | )
> The second problem is that you are defining a slot at the prompt, but
> slots can only be defined inside some object. Before we had a GUI (Self
> 4) we did stuff like:
> lobby _AddSlotsIfAbsent: ( | person = ( | name. age. test = ( 'test'
> printLn ) | ) | )
> If that works, you can then try this at the prompt:
> person test
> This example has at least two problems even if it works: the new person
> object doesn't have any traits, like clonable or oddball and its data
> slots don't have any interesting values, only nil.
> -- Jecel
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Self-interest