Updates to the tutorial

Pupeno pupeno at pupeno.com
Tue Aug 24 12:27:14 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm attaching the text, I finised reading the tutorial and this is the result, 
hope it helps.
- -- 
Pupeno: pupeno at pupeno.com - http://www.pupeno.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBK5aVfW48a9PWGkURAivDAKCDBL4yv/TqhYmWfYey3iGaJB6+KACeMxFn
aN5cA8Y5IgYO2/8ehZz7JK8=
=2q24
-----END PGP SIGNATURE-----
-------------- next part --------------
Introduction
============

Installation and Setup
======================

The tutorial was created for Slate 0.2.1 (as it is said at the begining of it). At that moment, Slated used to run over Lisp. Now (Slate 0.3.0), Slate has it's own virtual machine as it was expresed in the Introduction to Slate:
"Slate 0.3 will include a virtual machine, so that versions from 0.3 up will be self-hosting and no Lisp system necessary."
Personally, I'm not sure of all the changes that made, but the setup and installation seems to have changed a lot.
The current Slate Setup instruction should be something like:
 
$ tar xfz slate-0.3.tgz
$ cd slate-0.3
$ make
[Some lines of compiling]
$ ./vm little.image 
Slate: Growing heap to 4726380 bytes.
Hi, there!
Slate 1>

And that's it.
note: If you are in a big endian computer (x86s are little endian), you'll need to run ./vm big.image.
And that's it.

Slate's Object Model
====================

A Note on Syntax
----------------

In the table after "When methods from several categories are mixed, the order of precedence is that of the preceding rules. Evaluation always proceeds from left to right, so that:" I would put more examples. I would put mixes of unary and binary operator (in different orders) and mixes of unary, binary and keyword operators (in different orders). This examples are importart for newcomers. If I can, I'll try to create a table here with those examples.

Creating Slots
--------------
After "Let us then create a new object, by simply adding a slot to the lobby to store that object:" the output of Slate is no logger the same, now it's like this:
> lobby addSlot: #myObject.
(Mixins . Types . prototypes . VM .
        globals . myObject . traits )
This voids the description that follows: "The line starting with <@Namespace: ...> is the printable description of the object returned by the operation, the lobby in our case. The description includes the kind of object returned (a Namespace in our case) and the list of its slots. As the lobby serves as the top-level in the hierarchy of namespaces used by Slate, it includes a slot pointing to itself (the slot called lobby)."
 
After the couple of lines above, the following is run:
> myObject.
Nil
If you latter want to explain that lobby is a delegrate object of the current object/context (like it is done), I think it would be bettar to call it like this:
> lobby myObject.
Nil

It seems
> removeSlotNamed: #myObject.
3
should now be 
> removeSlot: #myObject.
(Mixins . Types . prototypes . VM .
        globals . traits )

And again:
> addSlot: #myObject valued: 43.
(Mixins . Types . prototypes . VM .
        myObject . globals . traits )
> myObject.
43

And again, but in this case, appart of the example that is like this:
> addImmutableSlot: #x valued: 37.
(Mixins . Types . prototypes . VM .
        myObject . x . globals . traits )
> x: 43.
The following condition was signaled:
The method #x: was not found for the following arguments:
{(Mixins . Types . prototypes . VM .
                myObject . x . globals . traits ).
        43}

The following restarts are available:
0)      Inspect a stack frame
1)      Abort evaluation of expression
2)      Quit Slate
Debug [0..2]: 1
Nil
the last sentences of the paragraph (maybe more) should be changed from: "We can see the error message and the back-trace. Typing in 0 when prompted for a place to restart execution from sent us back to the REPL and cleared the exception." to: "We can see the error message. Typing in 1 when prompted for a place to restart execution from sent us back to the REPL and cleared the exception." (maybe that sentence needs a little reviewing as well). And maybe, this would be a good place to explain what "Inspect a stack frame" is (at least, an overview).

Organizing Objects
==================

Clone and Copy
--------------

Again about running examples:
> addSlot: #Mario valued: Cloneable.
(Mixins . Types . prototypes . VM .
        Mario . globals . traits )
> addSlot: #Luigi valued: Mario clone.
(Mixins . Types . prototypes . VM .
        Mario . globals . Luigi . traits )
> Mario = Luigi.
False
> Mario traits = Luigi traits.
True

Oddballs
--------

I think the last lines of the example should be as follow:
> Nil traits printName. "Nil's only delegate is Oddball"
'Oddball'
since Nil traits name. produces an error.

Organizing Behavior
===================

Declaring Methods
-----------------

Again examples, the problem here is that, lines are numbered for further reference and the return of line 1 is now, two lines, I numerated them as one. It also seems ConsoleOutput doesn't exist anymore (I might be totally wrong) and that Console could be used instead; but Console doesn't have #; method, but #writeStream could be used instead.
1> addSlot: #cat valued: Cloneable copy.
2(Mixins . Types . prototypes . VM .
        globals . cat . traits )
3> _ at cat meow [ConsoleOutput writeStream 'Meeoooowww'].
4[meow]

After that, in the next example, I think there's a BIG difference, the tutorial says:
> cat meow. "order the cat to meow"
Meeoooowww
<@WriteStream:  name traits> "<-- this is ConsoleOutput"
>
When I run cat meow it did the following:
> cat meow. "order the cat to meow"
'Meeoooowww'
>
No object returned/printed.
The rest of the example:
> addSlot: #kitten valued: cat copy.
(Mixins . Types . prototypes . VM .
        kitten . globals . cat . traits )
> kitten meow.
'Meeoooowwww'
> _ at cat purr [Console writeStream 'rrrrrrrrr'].
[purr]
> cat purr.
'rrrrrrrrr'
> kitten purr.
The following condition was signaled:
The method #purr was not found for the following arguments:
{("Cloneable" traits: ("Cloneable" ...))}

The following restarts are available:
0)      Inspect a stack frame
1)      Abort evaluation of expression
2)      Quit Slate
Debug [0..2]: 1
Nil
> _@(cat traits) purr [Console writeStream '...'].
[purr]
> kitten purr.
'...'

To the following example I would add the following lines, to make it clear:
> cat purr.
'rrrrrrrrr'

In the following paragraph, this might not be right anymore: "The current Lisp interpreter is not always explicit in such cases, so you will have to be careful until you get used to this syntax" ;)

Latter, the method methodNamesAt: is used, but it seems not to exist anymore.



More information about the Slate mailing list