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.
Functions do not have declared return types. A function without an explicit return statement returns None . In the case of no arguments and no return value, the definition is very simple. Calling the function is performed by using the call operator () after the name of the function.
Using call() to invoke a function and without specifying the first argument. In the example below, we invoke the display function without passing the first argument. If the first argument is not passed, the value of this is bound to the global object. In strict mode, the value of this will be undefined .
To call a function which takes no arguments, use an empty pair of parentheses. Example: total = add( 5, 3 );
A function that takes a single argument as input, such as. , is called a unary function. A function of two or more variables is considered to have a domain consisting of ordered pairs or tuples of argument values. The argument of a circular function is an angle.
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.
A nullary or niladic function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With