On 3/5/08, Lars Hansen <[EMAIL PROTECTED]> wrote: > > > So, why a read/write, rather than a read-only, 'fixed' property? > > > It was my hunch when I designed that feature that code that uses > fixed-length vectors wants to be able to catch errors most of the time, > but also does not want to be stuck in the straightjacket that a > settable-but-not-resettable fixedness property creates, leaving it > unable to extend the vector in place after making it fixed.
I don't think I've ever encountered this feature in another language/library. I've seen the following: - Languages like Java that have a distinction between fixed-length arrays and variable length ones - Dependently typed languages that allow you to express the type "Array with length N" - Languages that provide immutable arrays (which goes beyond the fixed-length guarantee) in addition to mutable ones But I haven't seen vectors that can change from fixed- to variable-length and vice versa. So I guess I'm a bit skeptical of the demand for this feature. I'm trying to think of tasks where I need a vector to be a certain length for part of the computation and a different length for a different part -- and where I would also be upset to be forced to create a new vector (and copy into it) in order to accomplish that. (Of course, the "new vector + copy" is a simple invocation of the Vector constructor as a function.) Obviously, we can save the cost of the copy if we have the 'fixed' flag, but we don't get the benefit of having a nice invariant. Incidentally, since I brought up immutable arrays, above: intrinsic methods make it impossible to enforce immutability via subclassing, right? You could create an immutable sequence type through delegation, but not simply by overriding the mutators. Or is there a way to make the intrinsics unavailable publicly? -Jon _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
