Semantics of toString

Nick Sabalausky a at a.a
Thu Nov 5 12:59:18 PST 2009


"Justin Johansson" <free at beer.com> wrote in message 
news:hcuhet$15a2$1 at digitalmars.com...
>I assert that the semantics of "toString" or similarly named/purposed 
>methods/functions in many
> PL's (including and not limited to D) is ill-defined.
>
> To put this statement into perspective, I would be most appreciative of D 
> NG readers
> responding with their own idea(s) of what the semantics of "toString" are 
> (or should be)
> in a language agnostic ideology.
>
> If there are more than, say, two or three different views on the said 
> semantics then my
> "ill-definition" assertion is surely correct.
>
> If there are no replies on this matter, then guess I'm left concludeless.
>
> Just thinking in the language round-up that this is (just another) one of 
> the things
> we should address as a community.
>
> So what does "toString" mean to you?
>
> **beers,
> Justin
>
> **caveat: free beer offer available in-store only
>

(Deliberately not reading the other replies before posting...)

It means to me, obtain a string-representation of an object (or an instance 
of a non-class type) in whatever form is reasonably appropriate for the 
given type. This string representation might include all data, but this is 
not guaranteed. It might be unique to each object, but this is not 
guaranteed. It might be fully-suitable for serialization, but this is not 
guaranteed.





More information about the Digitalmars-d mailing list