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

Support Rest on non-extern methods too #3260

Closed
wants to merge 3 commits into from

Conversation

Simn
Copy link
Member

@Simn Simn commented Aug 18, 2014

I need an issue ID to write tests.

@Simn
Copy link
Member Author

Simn commented Aug 18, 2014

@ncannasse: Any objections to merging this? It works just like in AS3 where you get an array with the excess arguments.

@waneck
Copy link
Member

waneck commented Aug 18, 2014

Can we make it so that we get a haxe.ds.Vector instead of an Array? This would be nice to make it work with the native C# and Java rest arguments.

@Simn
Copy link
Member Author

Simn commented Aug 18, 2014

I still don't understand how this is even relevant to native representations.

@nadako
Copy link
Member

nadako commented Aug 18, 2014

I wonder if we need to add tests for extern Rest now that we have tests for non-extern Rest :-)

@waneck
Copy link
Member

waneck commented Aug 18, 2014

I meant that it would be nice that Rest on non-extern would be compiled like the actual extern Rest, on platforms that support Rest arguments

@Simn
Copy link
Member Author

Simn commented Aug 18, 2014

But then you would generate the extern-like call anyway without any array initialization, so I still don't see the point.

@waneck
Copy link
Member

waneck commented Aug 18, 2014

I'm not sure I understand - at least on Java (and IIRC on C# as well), you actually use the rest parameters as a native array, so they would be typed correctly when you declare a new Rest parameters function

@Simn
Copy link
Member Author

Simn commented Aug 18, 2014

That's getting too complicated for me again so let's forget about it for now.

@Simn Simn closed this Aug 18, 2014
@nadako
Copy link
Member

nadako commented Aug 18, 2014

The idea is good, let's not give up so quickly and wait for @ncannasse to say something 😉

@waneck
Copy link
Member

waneck commented Aug 18, 2014

I agree with nadako. It was just an idea, I can probably figure something out from the Java/C# side so it generates the native signature correctly

@Simn
Copy link
Member Author

Simn commented Aug 18, 2014

It's not worth it though because all it does is save you typing [ and ].

@waneck
Copy link
Member

waneck commented Aug 18, 2014

Allowing to override Rest functions would be a nice reason to allow this

@nadako
Copy link
Member

nadako commented Aug 18, 2014

If we're talking java/cs, it can do more that that, considering target interoperability.

For example it takes more than just [ ] when you want to create haxe array in C#, so it would be nice to be able to generate/override native rest-arg C# function (public void doStuff(int a, params string[] b)). In that case it indeed would be good to have haxe.ds.Vector as an underlying type for Rest.

After all, abstracts were designed to hide native stuff, so I even think it's okay to have different undelying types for different platforms (Array for flash/js, haxe.ds.Vector for Java/C#).

@waneck
Copy link
Member

waneck commented Aug 18, 2014

That's what I meant when I said to change the underlying type to Vector. Sorry I wasn't clear

@waneck
Copy link
Member

waneck commented Aug 18, 2014

Let's reopen this. I think it's worth - at least to have a better discussion about it.

@waneck waneck reopened this Aug 18, 2014
@nadako
Copy link
Member

nadako commented Sep 2, 2014

ping @ncannasse :)

@ncannasse
Copy link
Member

There's a bit of a design issue between a "native extern" where you want the rest parameters to be passed as-it and the "haxe extern" that needs to be passed as an Array. We tend to compile the whole Haxe code at once, but this feature would clearly break the ability to use haxe externs.

Any idea ?

@nadako
Copy link
Member

nadako commented Sep 2, 2014

Good point

@Simn
Copy link
Member Author

Simn commented Sep 2, 2014

What are "Haxe externs" actually used for?

@ncannasse
Copy link
Member

For example : sharing a Haxe/JS library among several projects ?

@Simn
Copy link
Member Author

Simn commented Sep 2, 2014

We could generate Rest as arguments on JS target. But again I feel this is getting to complicated and we should allow rest args only for externs. In that case we do not have to worry about the distinction because native externs are the only ones that can make sense of varargs.

@nadako
Copy link
Member

nadako commented Sep 2, 2014

Let's not introduce this for 3.2 and think some day later. I personally don't find rest args very useful and i can do that with macro anyway.

@nadako
Copy link
Member

nadako commented Sep 2, 2014

OTOH, the native method override argument is still valid

@ncannasse
Copy link
Member

if cl_extern || is_override ?

@waneck
Copy link
Member

waneck commented Sep 3, 2014

At some point we'll have to deal with these kind of differences (native extern vs haxe-generated extern).

@Simn Simn closed this Sep 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants