HaxeFoundation / HaxeFoundation/haxe
Allow pushing multiple values at once with arrays.
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Currently you can only push a single value at a time.
However some targets like JavaScript support pushing multiple values at once, and this functionality could be easily implemented into hxcpp too.
Allowing multiple values to be pushed at once would improve performance, as platforms could preallocate the required space for the requested amount of items, rather than reallocating each time a value is pushed
This feature seems like a good candidate to add to Haxe 5.x.x
If we don't want to risk breaking programs by making it `push(...val:T)`, we could make a new function named `pushAll(...val:T)`
Heres how to do it for different targets:
Javascript:
```js
array.push(...values); // takes up to 65535 arguments
```
Python:
```py
array.extend(values) # takes an array
```
Java:
```java
// if ArrayList is used internally
array.addAll(values); // takes an array
```
PHP:
```php
array_push($array, ...$values); // takes any amount of arguments
```
Contributor guide
Research direction
Review how array push operations are represented and implemented for the JavaScript, Python, Java, PHP, and hxcpp targets mentioned in the issue. Determine whether the existing push API should accept multiple values or whether a new pushAll function is needed; done means consistent multi-value behavior with target-specific preallocation where supported.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100