Skip leading space delimiters. Parse name delimited by a space. Create a definition for name with the execution semantics defined below. Return a struct-sys (zero or more implementation dependent items) that will be used by END-STRUCTURE and an initial offset of 0.
+n is the size in memory expressed in address units of the data structure. An ambiguous condition exists if name is executed prior to the associated END-STRUCTURE being executed.
While the name first school would define the same data structure as:
Although many systems provide a name first structure there is no common practice to the words used. The words BEGIN-STRUCTURE and END-STRUCTURE have been defied as a means of providing a portable notation that does not conflict with existing systems.
The field defining words (x
+FIELD) are defined so they can be used by both
schools. Compatibility between the two schools comes from
defining a new stack item struct-sys, which is
implementation dependent and can be 0 or more cells.
The name first school would provide an address (addr)
as the struct-sys parameter, while the name last
school would defined struct-sys as being empty.
Executing the name of the data structure, returns the size of the data structure. This allows the data stricture to be used within another data structure:
- For collecting related internal-use data into a
convenient "package" that can be referred to by a
single "handle". For this use, alignment is important,
so that efficient native fetch and store instructions
can be used.
- For mapping external data structures like hardware register maps and protocol packets. For this use, automatic alignment is inappropriate, because the alignment of the external data structure often doesn't match the rules for a given processor.
Many languages cater for the first use, but ignore the
second. This leads to various customized solutions, usage
requirements, portability problems, bugs, etc.
+FIELD is defined to be non-aligning, while the
named field defining words (x
aligning. This is intentional and allows for both uses.
The standard currently defines an aligned field defining word for each of the standard data types:
|FIELD:||a native integer (single cell)|
|FFIELD:||a native float|
|SFFIELD:||a 32 bit float|
|DFFIELD:||a 64 bit float|
Although this is a sufficient set, most systems provide facilities to define field defining words for standard data types.
|1 byte (8 bit) field|
|16 bit field|
|32 bit field|
|64 bit field|