-
-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector.fill #10687
Vector.fill #10687
Conversation
I'd expect this to be an instance method. |
You cannot generate filled non-nullable Vector in instance after |
Oh there are two functions... that is some rather confusing naming. I wonder if we can just support overloading the constructor for this. Not sure if that just works already. |
Is it? The naming makes sense to me. |
If the constructor route isn't possible, I think something like |
I'd like to see this improvement too. @RblSb could you please update your PR and change the name of the factory method from |
CI is not OK yet
|
@RblSb The tests are green now but I wonder if the same would need to be done for https://github.com/HaxeFoundation/haxe/blob/development/std/php/_std/haxe/ds/Vector.hx too |
Another option would be to just have the defaultValue as a new optional parameter to the constructor. Would there be any problems with that? |
public inline function new(length:Int, ?defaultValue:T) {
this = new java.NativeArray(length);
if (defaultValue != null) {
// fill
}
}
The php implementation is missing @:coreApi meta, could be why the missing fields didn't cause an error. |
Yes, but this bug reproduces even if you change any comment in something like std.StringTools, and maybe even with complex user-space code, macros, etc. I would like |
|
So to clarify, adding the extra constructor results in future changes to other classes breaking with the same error? In that case I think it's worth waiting for the issue to be investigated to see if we can use the overload constructor version. Also, for php you could use the native array_fill method, for example like this: tobil4sk@36dafd8. |
Should be good for merge |
I'm lowkey nervous about using this quite new overload mechanism on something important like Vector, but I guess it's a good thing because we'll know if it goes wrong very quickly. Will merge this once CI had some time to breathe. |
Closes #8040
This is only 2-4 times faster on js (node/chrome), btw.