void type
void is the absence of a type. It is used as the return type of functions
that produce no value.
Not a value
void has no size, no alignment, and no values. It cannot be stored,
passed, or returned. It only marks that a function returns nothing.
Usage
Function return type
A function with return type void produces no value:
func void f[]
// ...
end
Calling it leaves nothing on the stack:
call f
Untyped pointers
var ptr *void; // mark ptr as pointing to *anything*
Rules
voidcannot be used as a variable type:
var x void // error
voidcannot be used as a struct or union field type:
struct S
x void // error
end
voidcannot be a parameter type:
func f[void] // error
- A
voidfunction cannot return a value:
func void f[]
32 return // error: function returns `void`
end
- A non-
voidfunction must return a value:
func int f[]
// error: missing return
end