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

Better optional arguments #409

Merged
merged 3 commits into from
Jan 16, 2025
Merged

Better optional arguments #409

merged 3 commits into from
Jan 16, 2025

Conversation

irh
Copy link
Contributor

@irh irh commented Jan 16, 2025

This PR makes it easier to define optional arguments for functions.

Instead of checking for missing arguments in the function body (by checking against null), you can define default values in the argument list.

e.g. Instead of:

f = |a, b|
  a = a or 100
  b = b or 23
  a + b

you can write:

f = |a = 100, b = 23|
  a + b

Now that optional arguments are an explicit language feature, it makes sense for the runtime to be more restrictive and throw an error if a function is called with an unexpected number of arguments.

irh added 3 commits January 15, 2025 14:03
This makes space for a 'default arg count' field which will be
introduced in a later commit.
@irh irh merged commit c037114 into main Jan 16, 2025
8 checks passed
@irh irh deleted the default-argument-values branch January 16, 2025 12:21
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