You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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, becauseSince 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:
would be similarly unparseable.
The text was updated successfully, but these errors were encountered: