The great slice debate -- should slices be separated from arrays?

Steven Schveighoffer schveiguy at yahoo.com
Tue Nov 24 07:38:25 PST 2009


On Tue, 24 Nov 2009 10:19:57 -0500, Lutger <lutger.blijdestijn at gmail.com>  
wrote:

> Just to clarify, is it true that stomping over mutable arrays is covered  
> by
> the spec (currently), but stomping immutable arrays is classified as a  
> bug?
> I was very surprised by this.

Stomping of arrays is covered by the spec (without reference to how it  
affects immutability), but so is immutability, so technically it is an  
inconsistency in the spec, but it's an inconsistency that cannot be fixed  
without declaring that all append operations render other slices that  
alias the same data invalid.

See http://www.digitalmars.com/d/2.0/arrays.html#resize for the spec info  
on stomping, note there is no mention of immutability being compromised.

-Steve



More information about the Digitalmars-d mailing list