On 12/10/2011 11:41 PM, Andrei Alexandrescu wrote:
On 12/10/11 4:31 PM, kenji hara wrote:
Treating whole constant arrays as ranges by automatically shedding the
top-level const is good.
But realizing it by language semantic change is definitely bad.It
breaks IFTI rule, and adding special case will make difficult to learn
language.

Instead of language change, we can add specializations that receive
non-ranges and convert them to ranges by removing top-level const.
I believe that it is Phobos issue and is never the issue of language.

I should add there is precedent. C++ also removes top-level const when
passing objects by value to templates. Deducing top-level const with
pass-by-value is inherently nonsensical.

Andrei


Yes, but in C++ const is not transitive, so this change necessarily introduces some inconsistency. (for the better, I think)

struct S{int* x;}

void foo(T)(T t){ ... }

immutable int x;
foo(immutable(S)(&x)); // deduced type needs to be immutable(S)

Reply via email to