[ENH] That crazy dot idea II

Peter William Lount peter at smalltalk.org
Mon Mar 22 00:15:34 UTC 1999


Hi,

What about #at:ifAbsent:, #at:ifPresent:, #at:ifAbsent:ifPresent:,
#at:put:ifAbsent:, #at:put:ifPresent:, #at:put:ifAbsent:ifPresent:? 

The advantage to typing the full method selector is that you can have
related variations that have nice names that provide (in this example)
alternate flow control mechanisms. As you add shortcuts "[ ]", binary
selectors "&!@$*<>~", and other "features" you clutter the simple and
consistent message sending model of Smalltalk.

An important aspect of design in a system that allows flexibility to expand
the system is knowing what directions to not expand in. The real art of
design is making choices that really improve the system. An old quote:
"Just because you can do a thing does not mean that you do the thing".

I personall think that clear, concise, and complete message protocols (link
the selectors above) and improving the core objects in Smalltalk are a
better direction than focusing on cryptic "apl/c/pascal" like language
syntax shortcuts. But that's where diversity and freedom of opinion comes
in.

"a[12]" actually looks good and might even be considered to be more
readable, but what about the fault tolerant variations of #at:put: as
listed above? What does "a[12]" generate? "a at: 12"? How would I know
which method to lookup in a class? Or wouldn't it be better to take all of
the shortcuts like "a[12]" and treat them like a macro that gets processed
into actual source and then compiled? That way you can have as many of your
shortcuts as you like but all of others could just read the macro processed
source code with expanded method selectors!

There could be confusion with blocks with "[12]" or "[index]"! (Not for the
compiler since I assume your parser patch can digest the proposed syntax,
but with humans)!

Peter William Lount
peter at smalltalk.org
http://www.smalltalk.org

----------
From: Stefan Matthias Aust <sma at mail.netsurf.de>
To: squeak at cs.uiuc.edu
Subject: [ENH] That crazy dot idea II
Date: March 21, 1999 5:59 AM

Hi!

What do you think about using [ ] as an alternative to #at: and #at:put:?  

After refactoring the DotParser's messagePart:repeat: mega-method [1] if
was trivial to implement.  This extension to the Smalltalk grammar should
break any correct programs.  I find it quite useful.  Using "a[12] := a[12]
+ 1" instead of "a at: 12 put: (a at: 12) + 1" is easier to read IMHO.

Try yourself!

Attached is a new version of DotTest*.cs you can filein after applying the
ParserPatch*.cs file.


[1] note to SqueakCentral: If you like, I'd be glad to provide also a
    patch for the original Parser class or for a parser with just the
    []- but without .-access.

bye
--
Stefan Matthias Aust  //  ...and now something completely different





More information about the Squeak-dev mailing list