[Newbies] Re: Defining a binary message selector
mhaupt at gmail.com
Sun Nov 15 22:25:41 UTC 2009
On Sun, Nov 15, 2009 at 11:19 PM, Andy Burnett
<andy.burnett at knowinnovation.com> wrote:
> The specific problem I am having is:
> If I define an Integer method such as
> <<<*** aNumber
> Squeak is quite happy to let me create it. However, if I do something
> like fib aNumber, the compiler complains that aNumber is a unknown
> variable, which I need to define.
this is simpler than you may have thought. :-)
It's all about syntaaaaaaaaaaaaaaaaaaax. If you want to implement the
method as a binary message (with special characters), everything is
fine - as you yourself noticed. But if you want to implement it as a
so-called keyword message (i.e., where the selector consists of
alphanumeric characters), you have to insert a colon (:) after each of
The solution would be not to write
instead. That way, the parser knows where to look for parameters. ;-)
(((And if you have keyword messages with multiple parameters, use a
colon wherever a parameter needs to be placed, e.g., fib: aNumber fob:
anotherNumber fub: whatever - just browse the image to see how the
different things are done. But I assume you actually know that.)))
> So, what I was really trying to
> understand was what it was about the e.g. <<< symbol which allowed it to
> have an undeclared argument.
The argument to a binary message is not undeclared; the simple fact
that the message is binary *implies* there will be a parameter.
Am I making sense?
More information about the Beginners