[self-interest] Creating objects from the shell

Stephen De Gabrielle spdegabrielle at gmail.com
Fri Mar 14 16:36:10 UTC 2014


Thats brilliant,


lobby _AddSlotsIfAbsent: ( | person = ( | name. age. test = ( 'test' printLine
) | ) | )

In english,
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"
> "Self 1" lobby _AddSlotsIfAbsent: ( | person3 = ( | parent* = traits
> clonable . name . age | 'test' printLine ) | )
> lobby
> "Self 1"


I'm trying to make a method object and it seems to succeed,am I right about
the following;

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





--
Stephen De Gabrielle
stephen.degabrielle at acm.org
Telephone +44 (0)20 85670911
Mobile        +44 (0)79 85189045
http://www.degabrielle.name/stephen


On Fri, Mar 14, 2014 at 12:02 AM, Jecel Assumpcao Jr.
<jecel at merlintec.com>wrote:

>
>
> Stephen,
>
>
> > 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...
URL: <http://lists.selflanguage.org/pipermail/self-interest/attachments/20140314/b2db40ed/attachment.html>


More information about the Self-interest mailing list