BlockML Documentation

Struct Types

Shape described by ordinary properties

StructType is the abstract branch for composite value objects — its properties define the value's data layout, with no special struct syntax beyond ordinary Property declarations.

Named access and significant field order

A struct field is read exclusively by name, such as size.x — numeric index access on a StructType is not valid, because a StructType is a typed object with named properties only.

Field declaration order remains significant for capability call mapping and for compatibility across versions — existing field order must not change, and new fields may only be appended at the end.

EmptyStruct — the named counterpart of {}

type:EmptyStruct is a named, reusable StructType with no fields — usable anywhere a StructType is required and no fields are needed, and not itself abstract.

Declaring and configuring a struct value

A StructType Block declares its fields as ordinary properties, and a Property of that type is configured with a named object literal.

<!-- Point is a StructType declaring "x" and "y" as ordinary properties -->
<acme:Point xmlns="http://blockml.org/bml"
  xmlns:acme="com.acme.example"
  xmlns:type="org.blockml.bml.type">

  <baseType>
    type:StructType
  </baseType>
  <properties>
    <x type="type:Integer" />
    <y type="type:Integer" />
  </properties>
</acme:Point>

<!-- Widget declares a Property typed acme:Point -->
<acme:Widget xmlns="http://blockml.org/bml"
  xmlns:acme="com.acme.example"
  xmlns:core="org.blockml.bml.core">

  <baseType>
    core:Block
  </baseType>
  <properties>
    <position type="acme:Point" />
  </properties>
</acme:Widget>

<!-- An instance configures position with a named object literal -->
<acme:Widget bml:id="firstWidget" position="{ x: 4, y: 2 }" />

The declaration order of x then y in Point is what a positional configuration would rely on, while the named literal { x: 4, y: 2 } shown here reads each field by its declared name regardless of order.

What to carry into the next pages

After this page, readers should be able to define a StructType and configure a struct value, before contrasting it with the closed-set EnumType branch next.

Continue with enum types