help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] asString for Floats?


From: Stephen Compall
Subject: Re: [Help-smalltalk] asString for Floats?
Date: Sun, 05 Nov 2006 22:21:19 -0600
User-agent: Thunderbird 1.5.0.7 (Macintosh/20060909)

Michael Fellinger wrote:
>> st> #($p $o $n $g) asString printNl!
>> 'pong'
>> st> #($p $o $n $g) printNl!
>> ($p $o $n $g )
>>
>> Languages that rely on a single method convert-to-string protocol blur
>> this important distinction.
> 
> My brain very much appreciates blurring such things, as it helps 
> concentrating 
> on the problem, not the implementation ;)

If it helps, #printString is the universal protocol (applicable to all
objects), whereas #asString is specific to a few objects that have
equivalent representations as strings.

I think Java's toString() was supposed to offer similar functionality
as the #printOn: protocol; they just forgot that when writing some of
the methods.  This is too bad.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog
##smalltalk,#gnu-smalltalk on Freenode IRC




reply via email to

[Prev in Thread] Current Thread [Next in Thread]