[squeak-dev] The Trunk: SUnit-eem.91.mcz

Levente Uzonyi leves at elte.hu
Wed Feb 6 17:18:33 UTC 2013


On Wed, 6 Feb 2013, Chris Muller wrote:

> Kent Beck makes a case for using #print: in his Reversing Method
> pattern on page 33 of the original "Smalltalk Best Practice Patterns",
> but the basis for that is to avoid having messages going to different
> receivers on every line.
>
> If Eliot had used
>
>  self class printOn: aStream.
>  aStream nextPutAll: '>>#'.
>  testSelector printOn: aStream
>
> then Kents argument would apply.  However, since Eliot has a nice
> cascaded flow of messages all going to the same receiver, the
> Reversing Method isn't necessary.
>
> Having said that, I normally prefer not to send #printString to any
> object inside a printOn: method -- since that object should just be
> able to print itself on the stream.  So I think print: would be nicer:
>
>  aStream
>     print: self class;
>     print: '>>#';
>     print: testSelector
>
> BUT, having said THAT, the caveat with #print: comes with Strings and
> Characters -- that they print the syntax punctuation; strings
> surrounded by single-quotes and Characters prefixed with '$' rather
> than simply printing the contents like nextPutAll:.

Um, yeah. That's why I used #nextPutAll: and '>>'. The last #print: will 
print the #, if testSelector is a symbol. And there's no need for quotes 
around >>.


Levente

>
> - Chris
>
>


More information about the Squeak-dev mailing list