[top]
[prev]
[next]

## New

An allocation operation has the form:

NEW(T, ...)

where `T` is a reference type other than `REFANY`,
`ADDRESS`, or `NULL`. The operation returns the address of a
newly-allocated variable of `T`'s referent type; or if `T`
is an object type, a newly-allocated data record paired with a method
suite. The reference returned by `NEW` is distinct from all
existing references. The allocated type of the new reference is `T`.
It is a static error if `T`'s referent type is empty.
If `T` is declared as an opaque type,
`NEW(T)` is legal only in scopes
where `T`'s concrete type is known completely,
or is known to be an object type.

The initial state of the referent generally represents an arbitrary
value of its type. If `T` is an object type or a reference to
a record or open array then `NEW` takes additional arguments
to control the initial state of the new variable.

If
`T` is a reference to an array with k open dimensions, the
`NEW` operation has the form:

NEW(T, n_1, ..., n_k)

where the `n`'s are integer-valued expressions that specify the
lengths of the new array in its first k dimensions. The values in
the array will be arbitrary values of their type.
If
`T` is an object type or a reference to a record, the `NEW`
operation has the form:

NEW(T, Bindings)

where `Bindings` is a list of keyword bindings used to initialize
the new fields. Positional bindings are not allowed.
Each binding `f := v` initializes the field `f` to the value
`v`. Fields for which no binding is supplied will be initialized
to their
defaults
if they have defaults; otherwise they will be
initialized to arbitrary values of their types.

The order of the field bindings makes no difference.

If `T` is an object type then `Bindings` can also include
method overrides of the form `m := P`, where `m` is a method
of `T` and `P` is a top-level procedure constant. This is
syntactic sugar for the allocation of a subtype of `T` that includes
the given overrides, in the given order.
For example, `NEW(T, m := P)` is sugar for

NEW(T OBJECT OVERRIDES m := P END).

[top]
[prev]
[next]