Previous: , Up: Structs   [Contents][Index]


14.5.18 Struct Attributes

The following attributes are defined for struct values.

size

Gives an offset with the storage occupied by the complete struct. Example:

(poke) type Packet = struct { byte s; byte[s] d; }
(poke) (Packet { s = 3 })'size
32UL#b
length

Gives the number of fields stored in the struct. Note that, due to absent fields, this doesn’t always corresponds to the number of fields that appear in the definition of a struct type.

For example, for the following struct type:

type Packet =
  struct
  {
    byte magic: magic in [0xff,0xfe];
    byte control if magic == 0xfe;
    byte[128] payload;
  };

We get the following results:

(poke) (Packet { magic = 0xff })'length
2UL
(poke) (Packet { magic = 0xfe })'length
3UL
mapped

Boolean indicating whether the struct is mapped.

strict

Boolean indicating whether the struct is mapped in strict mode.