Sign in Join
FPDoc Onlineexperiment

Default function

In unit System

Return Default initialized value.

Declaration

pascal
function Default(const T: AnyType): AnyType

Description

Default is a compiler intrinsic: it returns for every type T a default value. In essence, this is a block of memory that is zeroed out. It can be used to correctly initialize most types (see below). Most importantly, it can be used to correctly initialize a managed type. It also works using a generic type template.

This function must not be used on a type where 0 (or a block of zeroes) is not a valid value for that type. In particular, it must not be used on the file types or complex types that contain a file type. Similarly, if you use it on enumerated types and range types which do not have an element with ordinal value 0, the use of this function will result in invalid values. In both cases, the compiler will not give an error if you do use Default on variables of the mentioned types, but the result will be an invalid value.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.