[squeak-dev] Changeset: articles.1.cs

Chris Muller asqueaker at gmail.com
Mon Jan 20 22:10:19 UTC 2020

Sorry Christoph, I'm not a fan of this one.  IMO, such an abstraction isn't
worth poaching such a common word, #article, from availability for
applications and expanding Squeak's core API with it, especially for
something of such limited use.  Many objects already care enough to provide
their own #printOn: anyway (sometimes not even calling super).  There's no
multilingual hook here (not that there should be one, for this I think
there shouldn't) since, even if it *was* possible to replace regular
Strings with one's own subclass, that isn't how one would handle
internationalization in Squeak.

Instead of adding code to increase printing of type information, the
abstraction *I* like for #printOn: is one that could *exclude* the printing
of it entirely, and assures a *terse, one-line* print (like, < 80
characters) which identifies the object to the user, but excludes
unnecessary data details like its "type" (class).  Numbers and Dates and a
few others do this by default, but I like this style to be available for
all types as an "alternate" #abbreviatedPrintString, depending on the
use-case I'm printing it for (e.g., as elements of a Collection).

Anyway, I call it #printAbbreviatedOn: in my own code, and even though it's
been useful to me over two decades and I still use it, I never actually
proposed it for trunk because just the one level of intercept, #printOn:,
has proven to be *just the right amount* of abstraction for object printing
in a general sense.  Simplicity and resilience from original Smalltalk-80
that has withstood the test of time.


On Sun, Jan 19, 2020 at 4:03 PM Thiede, Christoph <
Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:

> Hi all, please take a look at the following changeset. It eliminates
> a lot of duplication for printing a string with article, for example:
> | title |
> title := self class name.
> aStream
> nextPutAll: (title first isVowel ifTrue: ['an '] ifFalse: ['a ']);
> nextPutAll: title.
> <http://www.hpi.de/>
> With this changeset, the example is rewritten much simpler as:
> aStream nextPutAll: self class name asString withArticle.
> (Additionally, this unification provides a possible hook, should we ever
> want to increase multilingual support. :))
> I tried to find as many occurrences as possible (6), but even if we don't
> replace them all, I would like to propose to put the following
> three methods into Trunk (which are part of the changeset, of course):
> String >> article
> ^ self first isVowel
> ifTrue: ['an']
> ifFalse: ['a']
> String >> withArticle
> ^ self article , ' ' , self capitalized
> Symbol >> withArticle
> ^ self article , self capitalized
> Theoretically, we could also put them into the '*System-Support' category.
> Not sure about this.
> Looking forward to your opinions :-)
> Best,
> Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200120/0a19b841/attachment.html>

More information about the Squeak-dev mailing list