Section6.8

]>
Book Contents Previous Section 6.7 Functions vs. Operations Next Section 6.9 How Axiom Determines What Function to Use Book Index

## 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. 9055783620 0662384514

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. 4241790073 3699697594

Type: Float

The only syntactic difference between delayed assignments and nullary functions is that you use ``()'' in the latter case.

Book Contents Previous Section 6.7 Functions vs. Operations Next Section 6.9 How Axiom Determines What Function to Use Book Index