Proposal: #symbol printing

Roel Wuyts rwuyts at vub.ac.be
Tue Apr 25 13:40:52 UTC 2000


The only thing I changed to obtain the proposal was to implement #printOn:
on Symbol to use #storeOn: as follows:

printOn: aStream

 self storeOn: aStream

The only thing that broke was the ChangeSorter (so we changed it to behave
correctly). All the rest has been working fine (both in 2.6 and 2.7) the
last months. However, while playing around before answering to your mail, I
noticed that it does not work correctly for non-literals, where the
following happens:

#'squeak rules' printstring

returns the string: '''squeak rules'' asSymbol',
which is clearly wrong ! We will have to fix that !

> There was some discussion about the "#" issue recently so let's
>
> PROPOSAL
>
> Change Symbol printString to emit
>
>    #xxx
>
> if xxx is a valid smalltalk identifier and
>
>    #'xxx'
>
> otherwise.  There should be already a method to determine whether a symbol
> is a valid identifer but I don't know its name at the moment.
>
> PROBLEMS
>
> A lot of stuff will break (especially in the Browser and other tools),
> mainly because
>
>    aStream print: aSymbol
>
> is (mis)used instead of
>
>    aStream nextPutAll: aSymbol
>
> This needs to be fixed.  As 2.8 shouldn't be affected by this change, I'd
> recommend to apply this change to 2.9a once its started.

Well, with the patch as proposed above (and submitted on this list a while
ago), there seems to be no problem. However, we have the same problem there
with the non-literals. I agree with the stuff below where you say that
printString etc. is for 'techical usage' and displayString is for GUI stuff.


> WORKAROUND
>
> Provide the old implementation in a method called #displayString.  Also
> provide a #display: method for Streams.  Then introduce the change and fix
> the problems that will occur by replacing #printString or #print: with the
> according display methods.
>
> Object>>displayString
>     ^ self printString
>
> Stream>>display: anObject
>     self nextPutAll: anObject displayString
>
>
> REASONING
>
> The refactoring goal is to eventually replace all textual display methods
> with special display methods and keep the print methods to the debugger and
> inspector.  The rule is:  printString is for the programmer to debug,
> displayString for the program to view.  The same framework is used in
> VisualWorks and Dolphin Smalltalk.
>
>
> bye
> --
> Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf
>
>


--
Roel Wuyts                    Programming Technology Lab
rwuyts at vub.ac.be              Vrije Universiteit Brussel
http://prog.vub.ac.be/~rwuyts
Webmaster of European Smalltalk User Group: www.esug.org





More information about the Squeak-dev mailing list