Re: Why do we persist in using "Transcript show:"? That hardly seems OO!

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Why do we persist in using "Transcript show:"? That hardly seems OO!

David Simmons
"Troy Brumley" <[hidden email]> wrote in message
news:[hidden email]...
> My first Smalltalk was ObjectStudio, and it has some neat ease of use
> features. One I like and find very intuitive is Object>>out.
> Instead of "Transcript show: anObject printString; cr." I can say

> out."
> A first implementation, which needs to be overridden for String to remove
> single quotes, is:
> out
>  "Display self upon Transcript in a reasonable format."
>  Transcript show: self printString; cr.
> I've watched some very bright people continue to type these long
> show:" commands ... why do we stay trapped in old patterns? Are there
> things we do routinely that could be done better and lessen the confusion
> new Smalltalkers?
> --
> Troy Brumley
> Lead Software Engineer, Smalltalk
> Cincom Systems, Inc.

QKS Smalltalk (and now SmallScript) has used #<< and #>> for a long time.
They are designed and implemented to parallel the functionality one finds in
C++ for the equivalent operators.


    Transcript << anObject << another << ...
    Console << anObject ...
    stdout << ...
    stdin << ...
    stderr << ...
    aStreamOfAnyType << ...
    anyIStream << ...
    Transcript <<% {format, arg,arg,....} << ...

The given object can then be supplied with a pattern and using OO it will
then in turn be sent a string output formatting message that includes the
stream so that it can then emit itself onto the stream as appropriate. A
default implementation of the string formatting operation in Object will
obtain the string form and place it on the stream.  This approach can also
be used to unify operations such as addAll:, our #add:, and can be
effectively applied to any target (i.e., it is useful for collections).

There are other habit based Smalltalk patterns that might be considered
anachronistic as well (and could be candidates for consideration as
deprecated forms).


Not every Smalltalker stays trapped in patterns (some Smalltalks didn't even
start with the same patterns). But as I'm probably considered to be a
Smalltalk radical/revolutionary who am I to say ;-).

-- Dave Simmons [ /]
  "Effectively solving a problem begins with how you express it."