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

Chris Muller asqueaker at gmail.com
Wed Feb 6 17:10:24 UTC 2013


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:.

 - Chris


More information about the Squeak-dev mailing list