Skip to content
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

auto-generated ctors vs Rest args #8531

Open
nadako opened this issue Jul 10, 2019 · 8 comments
Open

auto-generated ctors vs Rest args #8531

nadako opened this issue Jul 10, 2019 · 8 comments
Labels
Milestone

Comments

@nadako
Copy link
Member

nadako commented Jul 10, 2019

extern class A {
	function new(args:haxe.extern.Rest<Dynamic>);
}

class B extends A {}

will generate (JS, but also other targets, actually discovered on Flash):

var B = function(args) {
	A.call(this,args);
};
@nadako nadako added the bug label Jul 10, 2019
@RealyUniqueName RealyUniqueName added this to the Bugs milestone Jul 10, 2019
@RealyUniqueName
Copy link
Member

This probably should be handled in generators.

@nadako
Copy link
Member Author

nadako commented Jul 10, 2019

so we're (partially) implementing non-extern rest args?:)

@RealyUniqueName
Copy link
Member

Do we have any option currently to override extern methods with rest args?

@nadako
Copy link
Member Author

nadako commented Jul 10, 2019

Nope, also can't implement interfaces that require rest args.

@RealyUniqueName RealyUniqueName modified the milestones: Bugs, Design Jul 10, 2019
@nadako
Copy link
Member Author

nadako commented Jul 10, 2019

I think I'll add support for Rest<T> in the Flash generator for now, because I need these subclasses to work correctly.

@nadako
Copy link
Member Author

nadako commented Jul 10, 2019

OTOH this is annoying because we have to detect the cases where we have to generate super.call(rest) on Flash...

@RealyUniqueName
Copy link
Member

RealyUniqueName commented Jul 10, 2019

Personally I think we should support rest args in Haxe syntax. All (afaik) our targets support rest arguments. And if some of them don't then it's ok to implement it as

@:coreType abstract Rest <T> { 
    @:to function toArray():Array<T>...

@nadako
Copy link
Member Author

nadako commented Jul 12, 2019

I'm not a fan of rest args and the implicit allocations they usually bring. Also I don't think C/C++ support rest arguments like this. Newer C++ has the ...args syntax, but it's just a sugar for some templating magic for recursive functions, not something you can just turn into Array.

That said, maybe we should still have it for the sake of interop, just not in a nicely sugared syntax.

nadako added a commit to innogames/ax3 that referenced this issue Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants