[squeak-dev] Re: Selectors with underscores

Yoshiki Ohshima yoshiki at vpri.org
Wed Mar 17 20:56:10 UTC 2010

At Wed, 17 Mar 2010 20:44:04 +0100,
Nicolas Cellier wrote:
> 2010/3/17 Yoshiki Ohshima <yoshiki at vpri.org>:
> > At Fri, 12 Mar 2010 20:01:41 +0100,
> > Stéphane Rollandin wrote:
> >>
> >> > IMHO, both := and _ are wrong choices. To be consistent with selector
> >> > conventions, it should have been =: ( for assign:). But I guess it is too late
> >> > now.
> >>
> >> ah, but _ is not a selector
> >>
> >> now if a newly created identifier symbol was automatically bound to a
> >> specific instance of ProtoObject, instead of nil which is the sole
> >> instance of UndefinedObject, then =: could be implemented in ProtoObject
> >> as syntactic sugar for becomeForward:
> >>
> >> or am I wrong here ?
> >
> >  Hehe.  But if a variable (say an instance variable "x" of an object
> > "obj") already has a non-nil value, what does that mean?
> >
> >  In Smalltalk 72, the left arrow was a message to an atom, in deed.
> > The index finger hand literal object can be sent a string to get an
> > atom object and it in turn can receive an left arrow message with an
> > argument.  You can assign atom into another variable.  You can define
> > the left arrow message for a collection to mean "add" instead assign.
> > For an instance variable, you can use "'s" message followed by a
> > string also to get the corresponding atom in the reciver context.
> >
> > -- Yoshiki
> >
> Even in st80, instVarAt:put: and tempAt:put: still are messages
> anyway. It's just that there is a nicer syntax, and an optimized
> byteCode, but strictly speaking, Smalltalk does not require any
> assignment, nor does it require jumps.
> Think of basicAt:put:, it does nor even have a special syntax nor a
> byteCode (well, maybe I should check new closure byteCodes, but no
> image running).

  The answer is yes and no, I guess.  Yes, you can even introspect
contexts objects too, so Let us say we define a class called "Quote"
and on its class side, define doesNotUnderstand: to find out the
location of the named variable.  Then you could say:

  | a b |
  Quote a gets: Quote b.
  a gets: 42.
  b  "=> evaluates to 42"

or such, by using the primitives under at:put: and friends.  Or define
#++ to increment the variable.

  But being able to dispatch on the receiver's behavior, the nicer
syntax and optimization is a problem.  If you modify the compiler and
runtime so that you can write =: to mean assignment message, it may
not be "in Smalltalk-80", in my possibly subjective view...

-- Yoshiki

More information about the Squeak-dev mailing list