Semantics of toString

dsimcha dsimcha at yahoo.com
Thu Nov 5 13:27:29 PST 2009


== Quote from Don (nospam at nospam.com)'s article
> Justin Johansson wrote:
> > 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?
> It's a hack from the early days of D. Should be unavailable unless the
> -debug flag is set, to discourage people from using it. I hate it.

Why?  You've said this several times w/o giving your reason.  IMHO toString() is a
great way to get a default string representation of something.  If you care about
the formatting details, then you use a non-special method.  How else would you
recommend giving objects a sane default string representation?



More information about the Digitalmars-d mailing list