An interface can be thought of as the type of a structure. In its
basic form it is just a list of variable names, written (export
name
...). However, in place of
a name one may write (name
type
), indicating the type
of name
's binding.
The type field is optional, except
that exported macros must be indicated with type :syntax.
Interfaces may be either anonymous, as in the example in the introduction, or they may be given names by a define-interface form, for example
In principle, interfaces needn't ever be named. If an interface had to be given at the point of a structure's use as well as at the point of its definition, it would be important to name interfaces in order to avoid having to write them out twice, with risk of mismatch should the interface ever change. But they don't.(define-interface foo-interface (export a c cons)) (define-structure foo foo-interface ...)
Still, there are several reasons to use define-interface:
The compound-interface
operator forms an interface that is the
union of two or more component interfaces. For example,
defines bar-interface to be foo-interface with the name mumble added.(define-interface bar-interface (compound-interface foo-interface (export mumble)))
Previous: The configuration language | Next: Macros