<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
--></style><title>Re: Unary - Binary message</title></head><body>
<div>Gary --</div>
<div><br></div>
<div>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).</div>
<div> 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?</div>
<div><br></div>
<div>P.S. The Etoy system does implement "incremen" and
"decrement" and "multiply" as operations on
variables.</div>
<div><br></div>
<div>Cheers,</div>
<div><br></div>
<div>Alan</div>
<div><br></div>
<div>--------</div>
<div><br></div>
<div>At 11:08 PM +0100 10/24/01, Gary McGovern wrote:</div>
<blockquote type="cite" cite><tt><font
size="-1">Hello,</font></tt></blockquote>
<blockquote type="cite" cite><tt><font size="-1">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 :-)).</font></tt></blockquote>
<blockquote type="cite" cite> </blockquote>
<blockquote type="cite" cite><tt><font size="-1">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.</font></tt></blockquote>
<blockquote type="cite" cite> </blockquote>
<blockquote type="cite" cite><tt><font size="-1">Also, I'm working
through the Guzdial first book, is there a Swiki page that holds
questions and answers for the book ?</font></tt></blockquote>
<blockquote type="cite" cite> </blockquote>
<blockquote type="cite" cite><tt><font
size="-1">Thanks!</font></tt></blockquote>
<blockquote type="cite" cite><tt><font
size="-1">Regrads,</font></tt></blockquote>
<blockquote type="cite" cite><tt><font
size="-1">Gary</font></tt></blockquote>
<div><br></div>
<div><br></div>
<x-sigsep><pre>--
</pre></x-sigsep>
</body>
</html>