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

Variadic function arguments #55

Closed
nrigaudiere opened this issue Sep 27, 2023 · 0 comments · Fixed by #109
Closed

Variadic function arguments #55

nrigaudiere opened this issue Sep 27, 2023 · 0 comments · Fixed by #109
Assignees
Labels
feature New feature or request
Milestone

Comments

@nrigaudiere
Copy link
Member

nrigaudiere commented Sep 27, 2023

Let's say a JS function must accept a variadic arguments of Node as input, ...nodes.

We have 2 solutions to handle this on the native API:

  1. use the built-in slice, ie. []Node
  2. use a custom generated type, VariadicNodes generated through a provided helper function Variadic(comptime T: type) type

The slice solution is easier to use as you don't have to generate the Variadic<Type>. But it's also less explicit and can lead to some misunderstanding:

  • it's not a JS Array as the semantics might make you think (see Handle JS Array #52)
  • the Native -> JS translation will not be possible, therefore returning []Node will be forbidden, which is less obvious than forbid to return a VariadicNode
@francisbouvier francisbouvier added this to the Private Beta milestone Sep 28, 2023
@francisbouvier francisbouvier transferred this issue from another repository Sep 29, 2023
@francisbouvier francisbouvier added the feature New feature or request label Sep 29, 2023
@francisbouvier francisbouvier self-assigned this Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants