[self-interest] Questions about implied self

Jecel Assumpcao Jr. jecel at merlintec.com
Thu Feb 17 06:03:21 UTC 2011


Casey,

> So keyword messages eval right to left such than one needs to type
> less parens? I think this might explain why I've been having trouble
> typing in expressions that parse; I was under the impression that the
> capitalization trick took care of that, so, thinko there on my part. 

Where did you get the right to left thing from? Only binary selectors
with exactly the same name have an evaluation order in Self and
everything else needs parenthesis. Capitalization eliminates some
parenthesis (what would be the most inconvenient ones due to the lack of
an assignment operator) from nested keyword expressions.

> Questions...  
> 
> while I'm getting used to that, can I type the parens and then organize
> the message chain with the keyword parts left to right like I'm used to?

Yes, extra parenthesis don't hurt and can sometimes make an expression
more readable (sometimes less).

> Is the capitalization trick a syntactic req'ment in every case, or only in
> the case of disambiguating statements that suffer ambiguity resulting
> from the implied self?

It is part of the selector's definition. If you have #between:and: in
Smalltalk-80, it is 'between:And:' in Self. All but the first keywords
must be capitalized always.

> If I were to use an explicit self, does Smalltalk message syntax work in
> most cases? 

Pretty much, with the exception of super, assignments and cascades (see
below). There is a subtle semantic difference that might bite you: if
the last expression in the method does not start with a return ('^')
then its value is the return value anyway, while in Smalltalk-80 the
return value would be self.

> Is there a semantic difference between the implied self and the explicit
> self?

Only in one case: when the implicit self is used to access what would be
temporary variable or arguments in Smalltalk-80, replacing that with an
explicit self would instead access a slot in the receiver.

   sillyMethod = ( | x |
         x: 7. "temporary variable"
         self x: 9.  "instance variable"
   )

> I haven't encountered a "cascade message" yet; do these exist in Self?
> Does the cascade syntax stop being useful when the receiver is usually
> self and self is usually implied?

Self does not have cascades, so you have to create more temporary
variables than in Smalltalk-80. This simplification is independent of
the implicit self. Note that this means that ';' can be used as a
selector and it is used for array constructors since Self does not have
a literal syntax for arrays (called vectors in Self). So you have
expressions like    (3 ; 7 ; 2; 9) asVector

> I'm having a complete ball exploring Self. The object model is stunningly
> beautiful, and the Outliner is about the most refreshing thing I've seen in
> UI since discovering the halos in Squeak. 

The equivalent of halos in Self is the CoreSampler. I really miss it in
Squeak because each does some things better than the other.

Notice that I kept saying Smalltalk-80 above. That is because to me Self
is a Smalltalk, as is Slate.

-- Jecel




More information about the Self-interest mailing list