tank wrote:maxindex is all but useless.
So we don't need Array.Length? That's the main purpose that MaxIndex
already serves. It just has an unintuitive name and behaviour when there are no integer keys.
The point I share with joedf is there are tons of array proprties and functions that are necesay even though you disagree.
Clearly we can do (and have done) without them, therefore they are not "necesay". Of course there are many functions that would be
useful. Adding them is not what v2 is about, nor was my goal ever to have built-in methods for every potentially useful function.
Coco wrote:@lexikos, if a change of heart happens and this gets implemented, will it really affect performance or the other way around?
A change of heart is unlikely. That should work out well enough for you, since as I already said, I'm not against implementing it. No, it won't affect performance.
I was thinking of implementing both Length and Count. I'm not sure whether they would be properties (x.Length) or methods (x.Length()), or whether to use "Len" (as with RegExMatch objects; matches StrLen) or "Length" (more familiar for users of other languages). In any case, assigning
x.Length := ... would probably override the built-in property (though ObjLength() may be available).
There's enough overlap between Length and MaxIndex that I may also consider removing MinIndex/MaxIndex. The functionality they provide could be achieved other ways:
Code: Select all
x := new Object
x.Length := 0 ; For demonstration purposes.
MsgBox % x.MinIndex() ".." x.MaxIndex()
Loop 2
x[A_Index] := 1
, x.Length += 1 ; For demonstration purposes.
MsgBox % x.MinIndex() ".." x.MaxIndex()
class Object {
MinIndex() {
for k in this
if type(k) == "Integer"
return k ; Relies on Integer keys being enumerated in order.
else
return "" ; Relies on Integer keys always being first.
}
MaxIndex() {
return (this.Length || (this.HasKey(0) ? 0 : ""))
}
}
The only real benefit of removing them is reducing API/documentation clutter.
If not removed, I was considering whether MinIndex/MaxIndex should remain as methods() or become properties.