Dynamic Arrays & Class Properties

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu Aug 28 18:46:21 PDT 2008


"Bill Baxter" <wbaxter at gmail.com> wrote in message 
news:mailman.26.1219971010.19733.digitalmars-d-learn at puremagic.com...
> On Thu, Aug 28, 2008 at 3:39 PM, Denis Koroskin <2korden at gmail.com> wrote:
>>
>> There is also a final in D1:
>>
>> final char[] test = "hello";
>> test.length = 4; // Error: cannot modify final variable 'test'
>> test = "world";  // Error: cannot modify final variable 'test'
>>
>> but it doesn't work very well, too:
>> test[0] = '!'; // success
>
> I think that's correct behavior.  'final' is supposed to be a kind of
> head-const, no?  So all the bits of 'test' on the stack are immutable,
> but the bits on the heap are mutable.
>
>> and everything compiles "fine" with -v1 switch (what does it do?):
>> final char[] test = "hello";
>> test.length = 4; // no error
>
> If I'm not mistaken, -v1 means act like some antiquated version of the
> D compiler that no one cares about any more.

Or rather "follow the strict D1 spec" since there were breaking changes that 
came out after 1.000 that are not _technically_ part of D1.  ref, change in 
.init, string mixins, import expressions..  I call it "D 1.x" but I don't 
know what Walter's view on it is -- if the current D compiler actually _is_ 
D1 or if DMD 1.000 is. 




More information about the Digitalmars-d-learn mailing list