Dot notation and a crazy idea

Travis Griggs tgriggs at keyww.com
Thu Mar 18 23:58:06 UTC 1999


Bruce Cohen wrote:

> Marcel Weiher wrote:
>
> > In fact, a slightly extended version would pretty much solve the
> > syntactic difficulties I had with my ideas for sending messages to
> > multiple objects:
> >
> >         customers do : [ :each | each name capitalize ].
> > vs
> >         customers each name  capitalize do    " or other variants
> > vs
> >         customers.each.name capitalize
> > or
> >         customers.*.name capitalize
> >
>
> The "*" notation is a part of the GemStone syntax.  I  should have mentioned
> it in my previous message about the "O-O-ness" of dot notation, as a reason
> why breaking encapsulation is sometimes highly desirable.  Although, again,
> there's a way of presenting this as a generalization of message sends rather
> than as internal instvar access, using your "crazy idea".
>
> >
> > <crazy-idea>
> >
> > In fact, the whole business of refering to objects via name is
> > really just a special case of selection.  Which object do you want?
> > The one named 'bert'.
> >
> > Let's generalize this back to saying that a dotted name is really a
> > select statement.  So we could have something like:
> >
> >         customers.[ name == 'Kay' ].name capitalize.
> >
> > instead of
> >
> >         customers select: [ :each | each name == 'Kay' ] do: [ :each
> > | each name capitalize ].
> >
> > with the square-brackets thingy in the dotted path being a
> > simplified block, though maybe a full block would be better.  (Then
> > again, why shouldn't both types co-exist?)
> >
> > Add multiple method returns ( 'sendback' ), and ... wow!  Certainly
> > all sorts of 'generate-and-test' programs become one-liners.
> >
> > </crazy-idea>
> >
> > Marcel
> >
> > p.s.: Yeah, I know, it was all implemented in Smalltalk-72 and only
> > taken out later :-)
>
> I like it.  It makes the "map" functionality of select, which I admire
> greatly, much easier to read and write.

While I like to see the various ideas being punted around the "dot.notation"
stuff, I think "dot.notation" is itself an undesirable addition to the Smalltalk
syntax. There is a certain philosophical soundness to the current Smalltalk
syntax, which I think "dot.notation" violates. For more on why I think so, see
<http:http://brain.cs.uiuc.edu:8080/VisualWorks.Please+don't+Ruin+the+Elegance+of+the+Smalltalk+Syntax>.
I know some are going to argue that it is "natural" because it is used in other
computer languages, but if that's the argument, we might as well start using
curlies and semis a whole lot more.

--
Travis Griggs (a.k.a. Lord of the Fries)
Key Technology
tgriggs at keyww.com
Member, Fraven Skreiggs Software Collective
 - C for Sinking
 - Java for Drinking
 - Smalltalk for Thinking
 ...and Power to the Penguin!





More information about the Squeak-dev mailing list