On Friday, December 6, 2002, at 01:08  PM, Piers Cawley wrote:
He notes that VisualWorks Smalltalk makes the distinction between
'displayString', for the user oriented stringification and
'printString', for the programmer oriented.
One could imagine a scenario in which a user could accomplish an unlimited number of "styles" of stringification by creating multiple subclasses of C<Str>, one per desired style:

class FormalStr is Str;
class InformalStr is Str;

class PersonName {
...
method FormalStr { "$.hon $.first $.middleInitial\. $.last" }
method InformalStr { $.nick || $.first }
}

my PersonName $name = .new(...);
my FormalStr $s = $name; # "Dr. William P. Smith"
my InformalStr $s = $name; # "Bill"


Whether that is good, bad, or indifferent I leave to the OO Police. But the same approach could be used for Str and DebugStr, etc. It just depends on what audience we want Perl6 str's to be geared for.

(Ignoring the various context/coercion issues raised by the above.)

MikeL



Reply via email to