Error message issue
spir
denis.spir at gmail.com
Sat Mar 12 11:40:27 PST 2011
On 03/12/2011 01:45 PM, Russel Winder wrote:
> Coming from Java, C++, etc. where + is used for string concatenation I
> initially wrote:
>
> assert ( iterative ( item[0] ) == item[1] , "iterative ( " + to ! string ( item[0] ) + " ) = " + to ! string ( item[1] ) ) ;
>
> which results in:
>
> factorial_d2.d(45): Error: Array operation "iterative ( " + to(item[0u]) + " ) = " + to(item[1u]) not implemented
>
> which does seem a bit off the wall. Replacing + with ~ fixes the
> problem, but the error message above wasn't that helpful in being able
> to deduce this.
>
> I think this is somewhat more than a RTFM, or "you should know the
> basics of the language" in that D is very like C and Java and yet in
> this one place has chosen a different symbol for the operation.
>
> Not a big issue, just irritating.
Actually, I don't find this message bad, compared to many others. In fact, D
gives you rather too much information. "Operation '+' not defined for these
elements." may do the job better.
Note how happy you are that '+' is actually not defined for thoses types...
(IYSWIM)
Finally, the design decision of _not_ messing '+' with concatenation is a very
good one imo. The fact that most mainstream PLs (*) do the wrong thing is not a
worthy argument (for me). Also, the choice of '~' looks good, doesn't it?
Denis
(*) Even python, for once. Seems most Python design errors are C legacy, due to
Guido van Rossum's wish to please "C/Unix hackers".
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d
mailing list