Skip to content

Nullary functions #15

@Botffy

Description

@Botffy

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions