6.8 Delayed Assignments vs. Functions with No Arguments¶
In ugLangAssign we discussed the difference between immediate and function:with no arguments delayed assignments. In this section we show the difference between delayed assignments and functions of no arguments.
A function of no arguments is sometimes called a nullary function.
sin24() == sin(24.0)
You must use the parentheses () to evaluate it. Like a delayed assignment, the right-hand-side of a function evaluation is not evaluated until the left-hand-side is used.
Compiling function sin24 with type () -> Float
If you omit the parentheses, you just get the function definition.
Type: FunctionCalled sin24
You do not use the parentheses () in a delayed assignment...
cos24 == cos(24.0)
nor in the evaluation.
Compiling body of rule cos24 to compute value of type Float
The only syntactic difference between delayed assignments and nullary functions is that you use () in the latter case.