constancy and template parameters in D2.009+

guslay guslay at gmail.com
Thu Dec 13 08:41:57 PST 2007


Janice Caron Wrote:

> On 12/13/07, guslay <guslay at gmail.com> wrote:
> > I don't really understand the motivation behind the current behavior. Can someone explain why stripping away constness is not explicit?
> 
> Most of the time, stripping away head constancy is exactly what you
> want. Failure to do so results in multiple identical instantiations.

I am not convinced...

Identical specialization in code verbatim, maybe, but a.method() and const a.method() are not the same method call!

This is apart from the side effect that you lose const protection. Since we are talking about generic code, it seems like a safety issue.

Regarding coexistent multiple specializations, assuming they are all the same, i would like to know exactly in what respect this is detrimental. Yes, it increases executable size a bit. Are there are actual measures? Does that impact performance?

Also, how often does one instantiate all flavors (there are three) of const qualifications in an application?


> 
> But sometimes it matters, which is why Walter allowed the (T:T)
> notation, for when it does. I just think there has to be a better
> syntax for that!

I am all for a mecanism to discard const-qualification in the definition of the interface (as opposed to casting away const from the call site everywhere) if there are benefits. I just hardly see how this should be the default.






More information about the Digitalmars-d mailing list