Posted a test patch to realize the suggestion. https://github.com/D-Programming-Language/dmd/pull/554
Kenji Hara 2011/12/11 kenji hara <k.hara...@gmail.com>: > OK. I agree to the suggestion. > > I've been afraid that increasing IFTI rule is making the language > learning difficult. > It comes from the experience from implementing inout deduction for > template function. > > But also it is useful that removing top const when passing arguments by value. > C++ precedent convinced me. > > Thanks. > > Kenji Hara > > 2011/12/11 kenji hara <k.hara...@gmail.com>: >> 2011/12/11 Andrei Alexandrescu <seewebsiteforem...@erdani.org>: >>> 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 >>> >> >> Hmm, it's for sure. >> ---- >> void print_type(int){} >> >> template <typename T> >> void f(T p) >> { >> int n; >> p = &n; // OK, head is mutable >> //*p = 10; // NG, tail is const >> print_type(p); >> // Error: need explicit cast from int const * to int >> // T is deduced as int const * == top const is removed >> } >> int main() >> { >> int n; >> int const * const p = &n; >> f(p); >> return 0; >> } >> >> Kenji