Some variables must be initialized because they contain managed types. For variables that are declared in the var section of a function or in the main program, this happens automatically. For variables that are allocated on the heap, this is not necessarily the case.
For this, the compiler contains the Default intrinsic. This function accepts a type identifier as the argument, and will return a correctly initialized variable of that type. in essence, it will zero out the whole variable.
The following gives an example of its use:
The case where a variable is allocated on the heap, is more interesting:
It works for all types, except the various file types (or complex types containing a file type).
Remark: For generics, the use of Default is especially useful, since the type of a variable may not be known during the declaration of a generic. For more information section 8.7, page 440.