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

Nullary functions #15

Open
Botffy opened this issue Oct 18, 2019 · 0 comments
Open

Nullary functions #15

Botffy opened this issue Oct 18, 2019 · 0 comments

Comments

@Botffy
Copy link
Owner

Botffy commented Oct 18, 2019

Since parentheses are optional for functions with a single parameter, it would make sense to make the () optional when calling nullary functions, like in Pascal: a := f. This is a nice syntax. But that's unparseable, because

x := f
y := x

Since there's no opening parentheses, the parser assumes an argument will follow. Pascal tackles this by using mandatory statement separators. We don't, however, know when a statement ends. A x := f() syntax has no such problems, but it's kinda ugly.

Do we need nullary functions, though? The traditional answer is no, a nullary function is a constant. But functions can manipulate the global scope by using I/O mechanisms. A valid use case is a function that reads input into an array and returns it.

The same applies to procedures too:

f
y := x

would be similarly unparseable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant