Next: , Up: built-in   [Contents][Index]


6.1 The type of the void value

The type <void> is the type of the void object returned by void. We should never use <void> in a type annotation, because the only legitimate use of the void object is as single return value of functions returning “unspecified values” (under Vicare returning a single value is faster than returning zero values). If we need a unique value: we should use the sentinel value, see (vicare-scheme)The sentinel object.

Expressions of type <void> are deprecated as operands in function applications and forbidden in logic predicates. For example:

(display (vector-set! (vector 1) 0 2))

raises an exception because vector-set! returns the void value. The type <void> has no parent (it is not a sub–type of <top>) and it should be like not–a–number for numeric computations. Here are some consequences when the expander can determine the type of an operand:

The only function that is allowed to have a void operand is the core primitive void-object?.

Core Type: <void>

The type of the void object. <void> has no parent type. The union and intersection between <void> and any other type is <void> itself.

Constructor on <void>: <void> type-constructor

Return the void object.

Type predicate on <void>: <boolean> type-predicate obj

The type predicate is void-object?. Return #t if obj is void; otherwise return #f.


Next: , Up: built-in   [Contents][Index]