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)
Type: Void
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.
sin24()
Compiling function sin24 with type () -> Float
-0.90557836200662384514 |
Type: Float
If you omit the parentheses, you just get the function definition.
sin24
sin24()==sin(24.0) |
Type: FunctionCalled sin24
You do not use the parentheses () in a delayed assignment...
cos24 == cos(24.0)
Type: Void
nor in the evaluation.
cos24
Compiling body of rule cos24 to compute value of type Float
0.42417900733699697594 |
Type: Float
The only syntactic difference between delayed assignments and nullary functions is that you use () in the latter case.