Next: built-in top, Up: built-in [Contents][Index]
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:
<void>
with other types results in void:
(type-annotation-syntax (or <fixnum> <void>)) ⇒ <void> (type-annotation-syntax (and <fixnum> <void>)) ⇒ <void> (type-annotation-syntax (not <void>)) ⇒ <void>
and
, or
, xor
and test of if
will cause an expand–time syntax violation.
not
will cause an expand–time
syntax violation.
cond
and case
return void when no
else
clause is present and no clause matches: when
cond
or case
are used as operands, an else
clause is mandatory.
when
and unless
return void when the
body is not evaluated: when
and unless
cannot be used
as operands.
set!
cannot be operand expressions.
The only function that is allowed to have a void operand is the core
primitive void-object?
.
The type of the void object. <void>
has no parent type. The
union and intersection between <void>
and any other type is
<void>
itself.
<void>
: <void> type-constructorReturn the void object.
<void>
: <boolean> type-predicate objThe type predicate is void-object?
. Return #t
if obj
is void; otherwise return #f
.
Next: built-in top, Up: built-in [Contents][Index]