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

feat/arity - refactor to allow for variable number of arguments #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

liangyuanruo
Copy link

@liangyuanruo liangyuanruo commented Mar 5, 2024

Problem

Currently, the number of arguments of a function or method is fixed, as the AST is inflexible about the number of arguments that can be accepted in a function call.

This inhibits further language development as sometimes we would prefer to have an optional number of arguments.

For example, in #10 we do not have the option of providing the function UNIDECODE(string, [code_point_start, code_point_end]), as the number of arguments would have to be fixed as either 1 or 3, but not both,.

Solution

Move the valid arguments check into PlumberCallable's arity function, by refactoring it's type signature to arity(argsLength: number): boolean.

Tests

As we already have tests for global functions, this PR extends the coverage to include methods and inheritance, so as to ensure that no functionality has been broken.

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.

1 participant