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

[Design] variale number of arguments and default values #278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

khchen
Copy link

@khchen khchen commented Jul 18, 2022

Change the callable behavior: "extra arguments are thrown away; extra parameters get null" (like lua).
Moreover, parameters can have default value, even if the default value is an expression.

Example:

def foo
  return "hello"
end

def test(a = 10, b = a * 2, c = foo())
  print(c, a, b)
end

test()
test(0)
test(5)
test(5, 100)
test(5, null, "hi")

Output:

hello 10 20
hello 0 0
hello 5 10
hello 5 100
hi 5 10

@khchen khchen changed the title variale number of arguments [Design] variale number of arguments Jul 21, 2022
@khchen khchen closed this Jul 21, 2022
@khchen khchen reopened this Jul 21, 2022
@khchen khchen changed the title [Design] variale number of arguments [Design] variale number of arguments and default values Jul 22, 2022
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.

None yet

1 participant