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

Allow variadic arguments #155

Open
spinillos opened this issue Nov 20, 2023 · 2 comments
Open

Allow variadic arguments #155

spinillos opened this issue Nov 20, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@spinillos
Copy link
Member

When we have list of a single type (string, integer, etc), we are setting the array as signature. It implies that the function argument needs an array initialisation to make it works, when we could simplify the API changing it for variadic arguments.

Go:

// Signatures

// Before
func Tags(tags []string) {...}

// After
func Tags(tags ...string) {...}

// Usage

// Before
Tags([]string{"tag1", "tag2"})

// After
Tags("tag1", "tag2")

TS:

// Signatures

// Before
tags(tags: string[]) {...}

// After
tags(...tags: string[]) {...}

// Usage

// Before
tags(['tag1', 'tag2'])

// After
tags('tag1', 'tag2')
@spinillos spinillos added enhancement New feature or request good first issue Good for newcomers labels Nov 20, 2023
@julienduchesne
Copy link
Member

Two questions about this:

  • Should this be gated by a veneer or should we change every array that is the last argument?
  • What's the expectation of retrocompatibility? If this change is made, places where builder functions are called with arrays will not work on the functions that take in variadic arguments

@julienduchesne julienduchesne self-assigned this Dec 6, 2023
@julienduchesne
Copy link
Member

Will do it with a veneer

@julienduchesne julienduchesne removed their assignment Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants