Overview of External Types¶
External types let Quxlang name types that belong to another runtime even though Quxlang does not define their object layout. They are especially useful for managed-runtime classes.
External type declarations¶
::java_object INCLUDE_IF(ARCH_IS_JVM)
EXTERN_TYPE["java.base":"java/lang/Object"];
::java_point INCLUDE_IF(ARCH_IS_JVM)
EXTERN_TYPE["java.desktop":"java/awt/Point"];
The first string names the external scope or library, and the second names the
type within it. The Quxlang name before EXTERN_TYPE is what source code uses.
An INCLUDE_IF condition limits a platform-specific declaration to targets
that provide the declared external type.
Garbage-collected objects¶
Managed runtimes use ~>T references:
A default GC pointer is null. ?? tests whether it carries an object.
Checked casts¶
VAR object ~>java_object := stream AS CHECKED ~>java_object;
VAR checked_stream ~>java_print_stream :=
object AS CHECKED ~>java_print_stream;
Checked conversions ask the managed runtime to validate the target type. The external type remains opaque: its usable operations come from external procedure declarations, not Quxlang fields inferred from its external name.
See External Procedures for invoking runtime methods and fields.
Reference¶
See the External Types Reference for exact declaration, reference, casting, and layout rules.