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

Improve one-liner support #21

Open
2 tasks
jprochazk opened this issue Mar 10, 2023 · 0 comments
Open
2 tasks

Improve one-liner support #21

jprochazk opened this issue Mar 10, 2023 · 0 comments

Comments

@jprochazk
Copy link
Owner

jprochazk commented Mar 10, 2023

Allowed as statement terminators, in which case the next statement does not need to be on another line:

v := 0; print v # prints `0`

If the statement is on another line, normal indentation rules still apply:

v := 0;
  print v
# ^ error: invalid indentation
  • Pipeline operator

If the rhs is a single identifier, it is treated as a function with a single parameter.
If the rhs is any other expression, it must have at least one argument which is the identifier _ (maybe consider making this a keyword) - it is used as a placeholder, into which the expression on the lhs will be placed. The placeholder may appear multiple times in the rhs, but it is only evaluated once.

a() |> b |> c(_, option=true)

# desugaring:
_0 := a()
_1 := b(_0)
_2 := c(_0, option=true)


print (100 |> _ * _) # prints `10000`

# desugaring:
_0 := 100
_1 := _0 * _0
print _1
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

No branches or pull requests

1 participant