Immutable static arrays

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 16 21:31:47 PDT 2012


On Sat, Mar 17, 2012 at 02:59:55PM +1100, Daniel Murphy wrote:
[...]
> > So there's no tail-const type for static arrays?
> >
> > More to the point, how should AA's with immutable static array keys
> > be implemented? The current implementation doesn't work at all
> > because the input static array can't be assigned to the Slot (the
> > static array field in Slot is completely immutable, even from the
> > Slot ctor???).
[...]
> This is correct.  It's the same as for primitive types.  Because they
> implicitly convert to immutable, AAs should store a mutable copy.
> T[N] should be handled almost the same as T. 
[...]

So string[immutable int[4]] should store int[4] as key?

I guess I just found it strange that assigning to a string
(==immutable(char)[]) field is OK, but assigning to immutable(char[4])
is not.


T

-- 
Without outlines, life would be pointless.


More information about the Digitalmars-d mailing list