Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Type void

Fuzion's void type is the only type that does not have any values. Not having any values means that there is no means to produce a value of this type. Any feature with void as result type is therefore guaranteed never to return.

void result of endless loop

A simple way to create code whose result is of type void is an endless loop:

void result of non-returning features

Some intrinsic standard features also result in void, e.g. exit. Consequently, a feature that ends with a call to exit results in a void result:

void as a generic argument

void is sometimes useful as a generic argument if it should be impossible to provide any actual values of that type. An examples is an empty array, whose default type is array void. No values can be extracted from an empty array, since this would result in an index error:

void in absurd features

Using void as the type of an argument in a feature makes it impossible to call this feature since there is no way to produce a value of this argument's type. Such a feature is called absurd. In the previous example of using void as a type parameter, features that have arguments whose type is that type parameter will become absurd, the type system will ensure that these cannot be called.

This mechanism is also used to declare features just to declare their type but without permitting calls to the features. This is useful, e.g., in Fuzion's interface to Java code that declares absurd Fuzion features for Java classes. These features cannot be called from Fuzion code, but instances are created by intrinsics that use the types of these absurd features to wrap Java objects.

An example is Java.java.lang.String that is declared as follows:

  Java.java.lang.String(redef forbidden void) ref : Java.java.lang.__jObject(forbidden) ...