Question

Is there a term that describes a function that takes no arguments more concisely than "function that takes no arguments"? (In the same way that e.g. "higher order function" means "function that takes functions as arguments or returns a function")

I naturally think of "void", but I also think of side effects when I see "void". The situation I'm thinking of is the sort found in this discussion of constantly:

What is this functional "pattern" called?

where you might create a closure that takes no arguments, has no side effects, but still does something interesting.

Was it helpful?

Solution

A nullary function, usually: http://en.wikipedia.org/wiki/Arity

Whether a function has side-effects is orthogonal to how many arguments it has, so in a language where no function ever has side-effects, you don't need a more specific term. In languages with side-effects, I suppose you'd call it a "side-effect-free" or "pure" nullary function.

And then with (for example) memoization, a function can be logically pure even though you know that behind the scenes, it does have side-effects.

OTHER TIPS

A nullary or niladic function.

    

A Thunk?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top