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

Change C binding variadic syntax to splats #3120

Open
jhass opened this issue Aug 8, 2016 · 3 comments
Open

Change C binding variadic syntax to splats #3120

jhass opened this issue Aug 8, 2016 · 3 comments

Comments

@jhass
Copy link
Member

jhass commented Aug 8, 2016

From

lib X
  fun variadic(value : Int32, ...) : Int32
end

to

lib X
  fun variadic(*value : Int32) : Int32
end

Once #214 is implemented, the syntax for variadic callbacks should be

lib X
  type Callback = *Int32 -> Bool
end

The reasons are the same as always, replacing obsolete special cases with general constructs of the language.

@oprypin
Copy link
Member

oprypin commented Aug 8, 2016

You might be confused here. The ... doesn't mean more arguments of the same type may follow, it means any number of any type of argument may follow.

@jhass
Copy link
Member Author

jhass commented Aug 8, 2016

How about

fun variadic(value : Int32, *args : *T)
alias Callback = Int32, *T -> Bool

then?

@asterite
Copy link
Member

asterite commented Aug 8, 2016

Syntax aside, there's no way to currently hold a pointer to a variadic/splat proc. The concept doesn't exist in the language, and I have no idea how it could be implemented.

The best thing to do is to use a regular Proc, make sure it's not a closure, and then cast it to Void* and pass that as the callback.

@spalladino spalladino removed the RFC label Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants