On this page:
structure
structure?
define-structure
structure-supertype
structure-supertype*
Structure  Top
Structure  Top?
7.1

2 Untagged structures

Untagged structures are implemented as tagged structures, using a special tag name: untagged. The structure identifier and its derivatives therefore simply call tagged, filling in the tag name with untagged.

type expander

(structure fields-maybe-types)

 
fields-maybe-types = just-fieldᵢ ...
  | maybe-∀ field+type-descriptorᵢ ...
     
maybe-∀ = 
  | #:∀ (tvarⱼ ...)
     
just-fieldᵢ = fieldᵢ
  | [fieldᵢ]
     
field+type-descriptor = [fieldᵢ typeᵢ]
  | [fieldᵢ : typeᵢ]
     
fieldᵢ = Identifier
     
typeᵢ = Type
     
tvarⱼ = Identifier
Expands to the same type as (tagged untagged fields-maybe-types) would.

The elements may appear in any order, as long as the field descriptors form a contiguous sequence.

syntax

(structure maybe-instance maybe-∀ fields-maybe-types)

(structure maybe-builder  maybe-∀ fields+values-maybe-types)
 
maybe-instance = 
  | #:instance
     
maybe-builder = 
  | #:builder
     
tag-name = Identifier
     
maybe-∀ = 
  | #:∀ (tvarⱼ ...)
     
fields-maybe-types = just-fieldᵢ ...
  | [fieldᵢ : typeᵢ] ...
     
just-fieldᵢ = fieldᵢ
  | [fieldᵢ]
     
field+value-maybe-type = [fieldᵢ valueᵢ] ...
  | field+value+typeᵢ ...
     
field+value+typeᵢ = [fieldᵢ : typeᵢ valueᵢ]
  | [fieldᵢ valueᵢ : typeᵢ]
     
fieldᵢ = Identifier
     
typeᵢ = Type
     
valueᵢ = Expression
The first syntax expands to the same instance as (tagged untagged maybe-instance maybe-∀ fields-maybe-types) would.

The second syntax expands to the same builder function as (tagged untagged maybe-builder maybe-∀ fields+values-maybe-types) would.

The elements may appear in any order, as long as the field descriptors form a contiguous sequence.

match expander

(structure maybe-no-implicit field-maybe-patsᵢ ...)

 
maybe-no-implicit = 
  | #:no-implicit-bind
     
field-maybe-patsᵢ = fieldᵢ
  | [fieldᵢ patᵢⱼ ...]
     
fieldᵢ = Identifier
     
patᵢⱼ = "match pattern"
Expands to the same match pattern as (tagged untagged maybe-no-implicit field-maybe-patsᵢ ...) would.

The elements may appear in any order, as long as the field-maybe-patsᵢ form a contiguous sequence.

syntax

(structure? fieldᵢ ...)

(structure? [fieldᵢ : typeᵢ] ...)
(structure? [fieldᵢ predᵢ] ...)
 
  tag-name : Identifier
  fieldᵢ : Identifier
  typeᵢ : Type/Make-Predicate
  predᵢ : (ExpressionOf ( Any Any : typeᵢ))
The first syntax expands to the same predicate as (tagged untagged fieldᵢ ...) would.

The second syntax expands to the same predicate as (tagged untagged [fieldᵢ : typeᵢ] ...) would.

The third syntax expands to the same predicate as (tagged untagged [fieldᵢ predᵢ] ...) would.

The elements may appear in any order, as long as the field descriptors form a contiguous sequence.

syntax

(define-structure maybe-predicate? name fields-maybe-types)

 
maybe-predicate? = 
  | #:? predicate-name?
     
tag-name = Identifier
     
fields-maybe-types = just-fieldᵢ ...
  | maybe-∀ field+type-descriptorᵢ ...
     
maybe-∀ = 
  | #:∀ (tvarⱼ ...)
     
just-fieldᵢ = fieldᵢ
  | [fieldᵢ]
     
field+type-descriptor = [fieldᵢ typeᵢ]
  | [fieldᵢ : typeᵢ]
     
fieldᵢ = Identifier
     
typeᵢ = Type
     
tvarⱼ = Identifier
Defines name and predicate? in the same way as (define-tagged #:tag untagged maybe-predicate? name fields-maybe-types) would.

The elements of the grammar for define-structure may appear in any order, as long as the field descriptors form a contiguous sequence.

type expander

(structure-supertype field+typeᵢ ...)

 
field+type = [fieldᵢ typeᵢ]
  | [fieldᵢ : typeᵢ]
Expands to the same union type as (tagged-supertype untagged field+typeᵢ ...) would.

match expander

(structure-supertype maybe-no-implicit field-maybe-patsᵢ ...)

 
maybe-no-implicit = 
  | #:no-implicit-bind
     
field-maybe-patsᵢ = fieldᵢ
  | [fieldᵢ patᵢⱼ ...]
     
fieldᵢ = Identifier
     
patᵢⱼ = "match pattern"
Expands to the same match pattern as (tagged-supertype untagged maybe-no-implicit field-maybe-patsᵢ ...) would.

The elements may appear in any order, as long as the tag name appears before any field descriptor, and as long as the field descriptors form a contiguous sequence.

syntax

(structure-supertype* )

Currently not implemented. Will be equivalent to nesting structure-supertype.

The supertype of all untagged structures, including tagged structures, constructors and nodes using the tag name untagged. It does not include tagged structures, constructors or nodes with other tag names than untagged.

procedure

(StructureTop? v)  Boolean

  v : Any
A predicate for StructureTop. It accepts all untagged structures, including tagged structures, constructors and nodes using the tag name untagged, and rejects any other value.