Feature Request: Allow to modify read-only attribute length for arrays

43 views
Skip to first unread message

Алексей Винокуров

unread,
Nov 19, 2013, 3:27:25 PM11/19/13
to haxe...@googlegroups.com
In actionscript it's quite practical to set array length attribute in order to quickly set up array size or clean it without iterated "pop" mess or creation of the new instance. I suppose it's quite low-level and not clean trick but it's very handy and looks clean in the code.

Juraj Kirchheim

unread,
Nov 19, 2013, 4:19:33 PM11/19/13
to haxe...@googlegroups.com
To clean use `array.splice(desiredLength, array.length -
desiredLength)`. To grow an array (although I'm not sure why you'd
need that), you can do `array[desiredLength-1] = null` (note that on
some platforms this may create sparse arrays which may not have the
performance characteristics that you're after).
> --
> To post to this group haxe...@googlegroups.com
> http://groups.google.com/group/haxelang?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Haxe" group.
> For more options, visit https://groups.google.com/groups/opt_out.

Hugh

unread,
Nov 19, 2013, 11:37:00 PM11/19/13
to haxe...@googlegroups.com
Yeah, this would be nice.

We could at least have an ArrayTools:

using ArrayTools;

myArray.setLength(100);

bu this is not as good.

Hugh

Алексей Винокуров

unread,
Nov 20, 2013, 1:49:22 AM11/20/13
to haxe...@googlegroups.com
Setting up size is usable for hash or cycle array that fills in random order and can grow sometimes. Splice loooks like good idea but it creates another instance of array and copies all deleted items to it -- it's rather expensive function.
Reply all
Reply to author
Forward
0 new messages