Fixing const arrays

kenji hara k.hara.pg at gmail.com
Sat Dec 10 15:01:57 PST 2011


2011/12/11 bearophile <bearophileHUGS at lycos.com>:
> kenji hara:
>
>> It breaks IFTI rule,
>
> What do you mean?

I mean following code comment will not become true.

void func(T)(T prm){}
void main(){
   X arg;
   func(arg);  // T is deduced to typeof(arg)
}

>
>
>> and adding special case will make difficult to learn language.
>
> I think that change proposed by Andrei A. (that I like) doesn't add a special case to D2. Currently (2.057beta) this works:
>
>
> void main() {
>    immutable(int[]) a = [1, 2];
>    immutable(int)[] b = a;
> }
>
> Calling a function that accepts a immutable(int)[] with a immutable(int[]) means creating a local slice, it's similar. So I think Andrei A. removes a special case.
>
> Bye,
> bearophile


More information about the Digitalmars-d mailing list