SRP port to slate

John Leuner jewel at pixie.co.za
Thu Jan 20 07:26:41 PST 2005


> - "n upTo: m - 1 do:" -> "n below: m do:"
> - and:,or: -> /\,\/
> - isNil ifTrue:ifFalse: -> ifNil:ifNotNil:
> - `>> works on any message sends, not just assignments, and returns the 
> left argument by default as the last block expression after a period.

So you can do:

(ExtensibleArray newSize: 5) `>> [ add: 1. add: 2. add: 'foo'.].
{"ExtensibleArray" 1. 2. 'foo'}

> Explicit ^ returns in single-expression methods or on the last 
> statement of any method are redundant.

Yes, in smalltalk you have to return explicitly otherwise you get
'self'.

> - "aFoo" named arguments are not helpful, and in fact misguide the user 
> into predicting what values and types will come through. Only 
> dispatches and type declarations or inferences are worth anything. (Or 
> contracts if someone wants to add them.)

So it's better to use a short variable name (like 'a') but add a type to
the argument to make it clear to the reader (and to make the program
safer).

> - Explicitly naming collection types like Set throughout the code leads 
> to brittleness. Just set up a Set newEmpty in a relevant prototype's 
> slot and use that as the prototype for new values of related usage 
> (especially for those stored into the same slot).

So create the collection at the same time as declaring the slot:

SRP Configuration addSlot: #exchangeRules valued: Set newEmpty.

and then either use the slot as is after cloning (it is pre-initialised)
or send newEmpty to the slot to get a collection of the defined type.

> - The precedence system of unary/binary/keyword is very simple and 
> should be used to minimize the number of parentheses used.

Yes, I am getting the hang of it. I still have to be careful with ^
though.

> - Don't trust the emacs indenter to get things right even half the 
> time. Ignore it mostly.

Unfortunately I turned off slate mode when I had to do a lot of pasting
from the squeak source, so the formatting is very messy.

> You should have picked something smaller to chew on first, as fixing 
> all of these requires a decent amount of tedious work or emacs-fu to 
> complete. :)

It doesn't matter for now, there is still a lot of work to be done to
make the code useful and hopefully by that time I will have more
experience and be able to clean it up relatively quickly.

John






More information about the Slate mailing list