auto: useful, annoying or bad practice?
Nick Sabalausky (Abscissa)
SeeWebsiteToContactMe at semitwist.com
Sat May 5 06:58:48 UTC 2018
On 05/04/2018 12:54 PM, H. S. Teoh wrote:
>
> This is a good point. However, I'm failing to see it as a big problem,
> because for it to be a problem in the first place, you have to have
> *deliberately* passed an object of said type into a function that
> expects that particular concept.
First of all, just to be clear in case I wasn't, I didn't mean that it's
equally dangerous as globals, just that it's analogous. Globals are, of
course, more dangerous.
Regarding the need to deliberately pass an object of said type to a
function in order to cause a problem, that's not always true: It could
be a matter of the compiler choosing the wrong overload. Or sticking it
in the wrong parameter on certain templated functions.
Also, generally speaking, even without structural typing, the danger of
passing an object of the wrong type to the wrong
parameter/function/overload IS considered to be significant enough to
help justify the whole premise of static typing. (Well, at least
according to a certain faction of programmers, anyway ;) )
And ultimately, from a design standpoint, I really see no compelling
reason *not* to require a formal declaration of "This deliberately
implements isXYZ", other than just...some people just dislike it. So
like, yea, we *can* get by without it...but...why would we want to?
More information about the Digitalmars-d
mailing list