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] command like function call #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khchen
Copy link

@khchen khchen commented Jul 30, 2022

The Language Manual says:

Note that a call of form f(fn ... end) is a syntax sugar for f fn ... end where f is a function or a method that takes a single literal function as argument, like Lua.

This patch extends it: parentheses for closure/method calling can be omitted if first argument is fn, name, string, number, primitive, map, list, etc.

Example:

a = 123
sum = fn (a, b) return a + b end

print 1, 2, 3
print "a", "b", "c"
print sum 10, 20
print "x:", sum(10, 20), "y:", sum(30, 40)
print [1, 2, 3]
print {1: 1, 2: 2, 3: 3}
print fn return 123 end (),
  fn return 456 end ()

Output:

1 2 3
a b c
30
x: 30 y: 70
[1, 2, 3]
{2:2, 1:1, 3:3}
123 456

…nt is fn,

name, string, number, primitive, map, list, etc.
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