Unary - Binary message

Alan Kay Alan.Kay at squeakland.org
Thu Oct 25 00:01:31 UTC 2001


Gary --

As far as the selector, just call it "inc" (unaries have to be 
identifiers). However, note the semantics of increment. It is not an 
operation on an integer (or number), these are immutable. It is 
really an operation on a variable of a particular type (if Squeak 
were typed).
      In Smalltalk-72, variables were regular objects and could be 
given messages and methods. In Smalltalk-80 (Squeak), this is not the 
case unless you make a change to the meta-system in the VM simulator 
and then make a new VM. A way around this is to make a class to hold 
numbers that can be incremented (we used to call this a "gauge"). If 
you stick one of these in a variable slot, then all will work pretty 
well. Can you see where you should subclass gauge?

P.S. The Etoy system does implement "incremen" and "decrement" and 
"multiply" as operations on variables.

Cheers,

Alan

--------

At 11:08 PM +0100 10/24/01, Gary McGovern wrote:
>Hello,
>I'd like to ask a serious question without being pelted with rotten 
>tomatoes. I've been trying to write an unary message to increment an 
>integer (++ but don't tell anyone :-)).
>
>But this won't work, I think because ++ is meant to be a binary 
>selector. I'm missing a bit info. Can someone give me a short 
>explanation on why I can't use this. I've managed the method with 
>other words OK.
>
>Also, I'm working through the Guzdial first book, is there a Swiki 
>page that holds questions and answers for the book ?
>
>Thanks!
>Regrads,
>Gary


-- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20011024/61c9bb15/attachment.htm


More information about the Squeak-dev mailing list