Perhaps naive question about the colon.

Andreas Nilsson wahboh at mac.com
Thu Dec 2 11:59:04 UTC 2004


Blake wrote:

> On Thu, 02 Dec 2004 19:05:01 +0800, Yar Hwee Boon 
> <hboon at motionobj.com>  wrote:
>
>>> caveman light fire with flintAndTinder usingForFuel twigsAndStraw.
>>
>>
>> Well.. at the very least, "caveman light fire with flintAndTinder  
>> usingForFuel twigsAndStraw" is already valid syntax now, its a chain 
>> of  simple message sends, no?
>
>
> Aha! It was a naive question.<s>
>
> Thanks for bearing with me. I've never gotten used to that construct. 
> Very  often in the code it's done with line-breaks, and I think I had 
> attributed  significance to those.
>
>
I'd say there's a difference between:
caveman light: fire with: flintAndTinder usingForFuel: twigsAndStraw

and:
caveman light fire with flintAndTinder usingForFuel twigsAndStraw

The first example is calling a method with arguments to tell it what to 
do while the second simply calls the methods twigsAndStraw, 
usingForFuel, flintAndTinder, with, fire and light on the caveman object.
You could, I suppose, write classes that has methods instead of 
arguments and rely on people calling them in the right order but I 
wouldn't recommend it.

The second example could also be used like this:
caveman flindAndTinder twigsAndStraw usingForFuel with fire light

/Adde



More information about the Squeak-dev mailing list