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

lock_free

API-Documentation: module lock_free

universe is the mother and father of all features. As such it is the outermost feature.

Universe can not be called but you can use it in a call as part of a full qualifier, e.g.:

Constructors

(T 
type
)
:
abstract_array T
 is
[Private constructor]
[Module base]
array -- one-dimensional immutable array

This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array

Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).
(T 
type
)
:
array T
 is
[Private constructor]
[Module base]
array(length0, length1) -- two-dimensional immutable array

array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
(T 
type
)
:
array T
 is
[Private constructor]
[Module base]
array(length0, length1, length2) -- three-dimensional immutable array

array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
:
Any
 is
[Module base]
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
:
Any
 is
[Module base]
envir -- unit feature to group environment related features
:
Any
 is
[Module base]
fuzion -- unit feature to group fuzion-infrustructure related features
(T 
type
:
integer, from T, through option T, step T)
:
Set T
 is
[Module base]
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.

In case step is positive (negative), the first value larger (smaller) than
through will not be included.

In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
lock_free -- unit type feature grouping lock-free
data structures and algorithms
:
Any
 is
[Module nom]
nom is a parser combinator framework
for more information go to:
https://github.com/Geal/nom/
 ref
:
Types
 is
[Private constructor]
[Module base]
Open_Types -- parent feature of type used for open types

This is the parent feature of the result type of open type parameters
such as `choice..CHOICE_ELEMENT_TYPE`.

The Open_Types value inherits from `Types` permitting access to
the individual types.
(T 
type
)
 ref
:
countable,orderable,hashable
 is
[Contains abstract features]
[Module base]
Sequence -- ancestor for features that can be converted to a 'list'

Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.

Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.

Heirs of Sequence must implement 'as_list'.
(A 
type
..., values A...)
:
orderable,hashable
 is
[Module base]
tuple -- feature used to define tuple types

tuple types provide algebraic product types of all the generic arguments
provided to tuple.

The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.

Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows


is equivalent to


The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.

Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in


In destructurings, we can denote values we are not interested in using
'_' as in

(_, b) := ("first", "second")

which will set 'b' to '"second"' and drop the first element of the tuple.

As an example, say we want to identify a person by its name and its age,
so we can define


Then, we could extract Bob's age using


or Claire's name using


Destructuring also works for general features, e.g.


and the destructured value can then be used to create a tuple


however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,


The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using


even though this has no effect.

An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:

(a0) := tuple a

which is equivalent to


NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.

tuples and destructuring can be used to swap two elements or create a
permutation as in


A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
 ref
:
Typed_Sequence
 is
[Private constructor]
[Module base]
Values_Of_Open_Type -- parent feature of type used for open types

This is the parent feature of the result type of fields with open
type such as `tuple.values` if called without selecting a particular
variant such as `tuple.values.2`.

The Values_Of_Open_Type value inherits from `TypedSequence` permitting access to
the types and values of the individual fields

Choice Types

list -- feature used to define lists

list provides an abstract type for a sequence of elements of the same type.

A list sequence may be empty and contain no element, or it may have a fixed
or even an infinite number of elements.

The core of the implementation of an actual list lies in the implementation
of the actual Cons cell a non-empty list consists of.

Lists can typically be traversed using only immutable data. This makes them
more flexible than streams that require to store and update their state.

A list is immutable, so it can be reused and shared between threads.
Due to the nature of lists, in which many Cons cells are used, a list
may require more (heap) allocation than an array.

(T 
type
)
:
switch T, nil,orderable,hashable
[Contains abstract features]
[Module base]
option -- feature wrapping a value or nothing

option represents an optional value of type T
(T 
type
)
:
switch T, error,equatable
[Contains abstract features]
[Module base]
outcome -- result type for functions that may return an error

outcome is a choice type that represents the result of a routine that
may either produce something useful or fail producing an error condition.

Several error conditions are needed if there are several very different
reasons for an operation to fail, e.g.


Note that 'outcome data IO_Error' is not assignment compatible with
'outcome data IO_Error Permission_Error', it has to be unwrapped first.
This unwrapping, however, requires very little boilerplate, it is done
using the '?' on the result of the call to 'read_file': This unwraps
'outcome data IO_Error' into 'IO_Error', which would be returned abruptly,
and 'data', which would be returned normally. Both are assignment
compatible to 'outcome data IO_Error Permission_Error', so everything
is fine.
(A 
type
, B 
type
)
:
choice A, B,monad A, switch.this,Sequence A,equatable
[Contains abstract features]
[Module base]
switch is the parent feature of all choices
that encode success and failure,
e.g. option (something/nil)
or outcome (something/error)
0.095dev (2025-10-09 18:01:25 GIT hash 4826e516431c193e428991dd546a46472973d8d4 built by fridi@fzen)
last changed: 2025-10-09