On this page:
statinfo
statinfo.macro
statinfo_  meta.wrap
statinfo_  meta.pack
statinfo_  meta.unpack
statinfo_  meta.pack_  group
statinfo_  meta.unpack_  group
statinfo_  meta.lookup
statinfo_  meta.gather
statinfo_  meta.union
statinfo_  meta.intersect
statinfo.key
statinfo_  meta.call_  result_  key
statinfo_  meta.index_  result_  key
statinfo_  meta.index_  get_  key
statinfo_  meta.index_  set_  key
statinfo_  meta.append_  key
statinfo_  meta.dot_  provider_  key
statinfo_  meta.sequence_  constructor_  key
statinfo_  meta.sequence_  element_  key
statinfo_  meta.values_  key
statinfo_  meta.indirect_  key
static_  info
static_  info
static_  info
8.12

7.10 Static Information🔗ℹ

The space for bindings of identifiers that provide static information.

definition

statinfo.macro 'id':

  body

  ...

Binds id in the static-information space to associate the static information produced by the body block. This static information applies to a use of id in the expression space. The static information produced by the body block must be in unpacked form (i.e., statinfo_meta.pack is applied automatically). The id is bound in the statinfo space.

See Annotations and Static Information for an example.

function

fun statinfo_meta.wrap(expr_stx:: Syntax,

                       statinfo_stx :: Syntax)

  :: Syntax

Provided as meta.

Returns a syntax object for an expression equivalent to expr_stx, but with the static information statinfo_stx attached. The statinfo_stx information must be in unpacked form (i.e., statinfo_meta.pack is applied automatically).

See Annotations and Static Information for an example.

function

fun statinfo_meta.pack(statinfo_stx :: Syntax) :: Syntax

Provided as meta.

Converts static information described by statinfo_stx into an opaque internal format. The given statinfo_stx must match the form

((key_id, val), ...)

Keys for static information are compared based on binding, not merely the key’s symbolic form. Key identifiers should be defined with statinfo.key.

See Annotations and Static Information for an example.

function

fun statinfo_meta.unpack(statinfo_stx :: Syntax) :: Syntax

Provided as meta.

The inverse of statinfo_meta.pack. This function is potentially useful to parse a result from statinfo_meta.lookup for a key whose value is packed static information.

function

fun statinfo_meta.pack_group(statinfo_stx :: Syntax)

  :: Syntax

 

function

fun statinfo_meta.unpack_group(statinfo_stx :: Syntax)

  :: Syntax

Provided as meta.

Analogous to statinfo_meta.pack and statinfo_meta.unpack, but for a sequence of static information sets, such as one set of static information per value produced by a multiple-value expression (see statinfo_meta.values_key).

An unpacked sequence is represented as a group syntax object, where each term in the group is unpacked static information in the sense of statinfo_meta.pack.

function

fun statinfo_meta.lookup(expr_stx :: Syntax,

                         key :: Identifier)

  :: maybe(Syntax)

Provided as meta.

Finds static information for expr_stx, which might be a name with static information associated to its binding, or it might be an expression with static information associated directly. The result is a syntax object for the value associated to key in that static information, or #false if no information or value for key is available.

When expr_stx is an expression, consider using expr_meta.parse_more to reveal additional static information by forcing an earlier expansion of the expression. Use the result in place of expr_stx, instead of continuing to use expr_stx (which could cause parsing and expansion to happen a second time for the same expression). A potential drawback of forcing expansion is that it might constrain the order of definitions in a recursive definition context; as a convention to limit such problems, avoid expansion of terms that are nested within a block.

Keys for static information are compared based on binding, not merely the key’s symbolic form. Key identifiers should be defined with statinfo.key.

function

fun statinfo_meta.gather(expr_stx :: Syntax) :: Syntax

Returns all of the static information of expr_stx in unpacked form. The returned static information corresponds to all the possible keys for which statinfo_meta.lookup would return a value.

function

fun statinfo_meta.union(statinfo_stx :: Syntax, ...) :: Syntax

 

function

fun statinfo_meta.intersect(statinfo_stx :: Syntax, ...) :: Syntax

Takes static information in unpacked form and combines it into one set of static information in unpacked form, where the returned information is the union or intersection of all given information.

definition

statinfo.key id:

  clause

  ...

 

clause

 = 

~union: union_proc_expr

 | 

~intersect: intersect_proc_expr

Binds id for use as a static info key identifier. Both union_proc_expr and intersect_proc_expr are required, and they should each produce a function that accepts two syntax objects as values for static information keyed by 'id'. The union operation is used, for example, on static information from annotations combined with &&, and interaction is used on static information from annotations combined with ||.

Typically, a definition statinfo.key id should be paired with a definition meta def id_key = 'id' so that id_key can be used directly as a key, instead of 'id'.

When a static information key is not an identifier bound via statinfo.key, then default union and intersection operations are used for the key’s values. The default functions use the same merge operations as statinfo_meta.call_result_key, which means that they merge nested static information.

Provided as meta.

Values that can be used to associate static information with an expression:

See Annotations and Static Information for examples using some of these keys.

class clause

static_info: body; ...

 

interface clause

static_info: body; ...

 

veneer clause

static_info: body; ...

A clause form for class, interface, or veneer that adds static information associated with the class or interface name as an annotation (i.e., static information for instances of the class or interface). The body sequence should produce static information in unpacked form, like the form accepted by statinfo_meta.pack.