February 08, 2005
Given this test code snippet:

> void test1(char[] s) { }
> void test1(wchar[] s) { }
> 
> void test2(byte[] s) { }
> void test2(int[] s) { }
> 
> void main()
> {
>   char[] s = "foo";
>   test1(s);
> 
>   static int[] i = [ 0, 1, 2 ];
>   test2(i);
> 
>   test1(cast(char[]) "bar");
> //test2(cast(byte[]) [0, 1, 2]);
> }


1)
Why does "i" require a static initializer ?
(or making as the variable static, as above)

> literals.d:8: variable literals.main.i is not a static and
>               cannot have static initializer

It seems to work just fine for the string ?

2)
Why could not the eg. int[] literals work as strings do ?
(in that you have to insert a cast to resolve overloads)

> literals.d:16: function literals.test1 overloads void(char[]s) and
>                void(wchar[]s) both match argument list for test1

I understand ambiguity is the biggest stop for those ?


Would this be helped if those literal arrays had
the proposed .readonly keyword attached to them ?

Or will those literals and the hash literals not
come until D 2.0 ("second coming"), no matter what ?

--anders