[Newbies] Color definition problem with robots

Jecel Assumpcao Jr. jecel at merlintec.com
Wed Oct 9 14:35:46 UTC 2019


> pica color: Color r:1 g:1 b:0 .
> 
> -this is as per the book but throws up a message 'MessageNotUnderstood:
> Bot>>color:r:g:b'

I would expect this to work

pica color: ( Color r: 1 g: 1 b: 0 ).

this sends the message #r:g:b: to the class Color and then the result of
that is used as the argument to the message #color: to the object pica.

Without the parenthesis you will be sending the message #color:r:g:b:
which, as the message informed you, pica doesn't understand.

There is a variation of Smalltalk called Self which changed the syntax
slightly to reduce this confusion a bit. In Self the first element of a
keyword message starts with a lower case letter while the second and
following parts start with capital letter. This allows you to get by
with fewer parenthesis since this code could be written in Self as

pica color: Color r: 1 G: 1 B: 0.

Of course, this causes its own set of confusions. So in Squeak we just
have to put in the parenthesis to make it clear what we mean. Note that
this has been this way since 1976, so it seems strange that the book
would get it wrong.

-- Jecel


More information about the Beginners mailing list