Skip to content

Explore user-side variadic functions. #5727

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

Closed
cristianoc opened this issue Oct 10, 2022 · 1 comment
Closed

Explore user-side variadic functions. #5727

cristianoc opened this issue Oct 10, 2022 · 1 comment
Labels
stale Old issues that went stale
Milestone

Comments

@cristianoc
Copy link
Collaborator

Here's a simple encoding and test:

module Variadic = {
  type t<+'a, 'r>

  let apply: (t<'a, 'r>, array<'a>) => 'r = %raw(`(f, args) => f(...args)`)
  let make: (array<'a> => 'r) => t<'a, 'r> = %raw(`(f) => (...args) => f(args)`)
}

let variadicFun = Variadic.make((a: array<_>) => Js.log(a))
let () = variadicFun->Variadic.apply([3])
let () = variadicFun->Variadic.apply(["a", "b"])

Relevant to the question of whether @variadic at the FFI level is necessary: rescript-lang/rescript-lang.org#572

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Old issues that went stale label Sep 28, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Old issues that went stale
Projects
None yet
Development

No branches or pull requests

1 participant