Symbol and Array printOn:

Stephane Ducasse ducasse at iam.unibe.ch
Wed Jan 12 09:17:48 UTC 2000


Hi David 

I send this email to the list becuase I think tother may be interested

> >Is there a reason why symbols and arrays are not printed with # like in VW
> >This has the main advantage that we can reuse a printed result while
> >evaluating another expression. Moreover the textual representation conveys
> >the fact that the expression is self-valuated (in the lisp metaphor).
> 
> I'd like the printed result to look like what I typed, too. (My 
> formatter does it that way.) However, #(#a #b #c #d) seems overkill; 
> I don't see how to cleanly fix it though and still get symbols to 
> print properly in other places
> 
> But, there is a problem with symbols which contain characters other 
> than those allowed in selectors. For example, both of these form 
> legal Squeak symbols:
> 
>     #'a b c'
> 
>     'a b c' asSymbol
> 
> To print them you need to do something like:
> 
>     '#', ((self select: [ :c | c isAlphaNumeric not ]) isEmpty
> 	ifTrue: [ self asString ]
> 	ifFalse: [ self asString printString ])
> 
> which is the code from my formatter. It prints the symbol #abc as 
> #abc and the symbol #'a b c' as #'a b c'. There are better ways to 
> detect special characters in a symbol that this, though!
> 
> Dave
> _______________________________
> David N. Smith
> IBM T J Watson Research Center
> Hawthorne, NY
> _______________________________
> Any opinions or recommendations
> herein are those of the author
> and not of his employer.

Stephane DUCASSE (ducasse at iam.unibe.ch) http://www.iam.unibe.ch/~ducasse/
"if you knew today was your last day on earth, what would you do 
different? ... especially if, by doing something different, today 
might not be your last day on earth" Calvin&Hobbes

University of Bern, Institut fuer informatik and Mathematik
IAM-SCG, 10 neubruckstrasse, CH-3012 Bern, Switzerland.






More information about the Squeak-dev mailing list