Why do we have transitive const, again?
Jason House
jason.james.house at gmail.com
Fri Sep 23 15:59:04 PDT 2011
Mehrdad Wrote:
> On 9/23/2011 11:47 AM, Jonathan M Davis wrote:
> > ...You'd have to duplicate functions all over the place... - Jonathan
> > M Davis
>
> Can't you avoid that trivially with templates?
While templates can be used to coerce a lot of similar things together, it's rarely done without good cause. If you want to pass a short into a function accepting ints, you usually won't templatize the function.
Probably more importantly, const getting added to D was a side effect of adding transitive immutability, and transitive immutability was a side effect of multithreading support. Head const and logical const do not exist in D because it was not required for multithreading.
If Walter thought everyone would use templates to join mutable and immutable together, then const would not exist at all in D.
More information about the Digitalmars-d
mailing list