Feature #220
closedAlignment attributes
0%
Description
Introduction¶
Attributes share the general syntax with traits: an attribute name is prefixed by # and is followed by arguments. The arguments are type expressions as in the case with traits, but constant expressions.
#aligned(16).
Alignment specified multiple time in the same position should be rejected.
Field alginment¶
The first attribute that should be supported is #aligned. Alignment can be specified for field and variable declarations. Declaration names are prefixed with attributes. If multiple declarations are separated by a comma (e.g. multiple fields with the same type) the attributes apply only to the immediately following name.
Parameters and fields share the same syntax, but since the parameters do not support alignment, this attribute should be rejected in the positions it is not supported.
Type alignment¶
Alignment can be also specified on records prefixing the record keyword:
The alignment is valid only on the record directly, so "attributed" aliasing like in type A = #aligned(16) R is not supported, even if R is a record.