Previous: , Up: descriptors   [Contents][Index]


4.6 Relations between type descriptors

The following syntactic bindings are exported by the library (vicare system type-descriptors).

Syntax: type-descriptor-parent ?type-annotation

Expand to an expression which, compiled and evaluated, returns the type descriptor of the parent of the specified type annotation.

(type-descriptor-parent <fixnum>)
⇒ <exact-integer>-ctd

(type-descriptor-parent (pair <fixnum> <flonum>))
⇒ <pair>-ctd

(define-record-type alpha)

(type-descriptor-parent alpha)  ⇒ <record>-ctd

(define-record-type beta
  (parent alpha))

(type-descriptor-parent beta)
→ (record-type-descriptor alpha)
Syntax: type-descriptor-ancestors ?type-annotation

Expand to an expression which, compiled and evaluated, returns the list of type descriptors representing the ancestors of the specified type annotation. The descriptor of the annotation itself is not included.

(type-descriptor-ancestors <top>)
⇒ ()

(type-descriptor-ancestors <string>)
⇒ (<top>-ctd)

(type-descriptor-ancestors <record>)
⇒ (<struct>-ctd <top>-ctd)

(type-descriptor-ancestors <nelist>)
⇒ (<list>-ctd <top>-ctd)
Syntax: type-descriptor=? ?type-annotation1 ?type-annotation2

Expand to an expression which, compiled and evaluated, returns #t if the type descriptors associated to the specified type annotations are equal; otherwise it returns #f.

(type-descriptor=? <top> <top>)
⇒ #t

(type-descriptor=? <top> <number>)
⇒ #f

(type-descriptor=? (pair <fixnum> <string>)
                   (pair <fixnum> <string>))
⇒ #t
Syntax: type-descriptor-super-and-sub? ?type-annotation1 ?type-annotation2

Expand to an expression which, compiled and evaluated, returns #t if the type descriptor associated to ?type-annotation1 is a matching super–type of the type descriptor associated to ?type-annotation2; otherwise it returns #f.

(type-descriptor-super-and-sub?
   <top> <top>)
⇒ #t

(type-descriptor-super-and-sub?
   <top> <number>)
⇒ #t

(type-descriptor-super-and-sub?
   <number> <top>)
⇒ #f

(type-descriptor-super-and-sub?
   (pair <fixnum> <null>) (list <fixnum>))
⇒ #t
Syntax: type-descriptor-matching ?type-annotation1 ?type-annotation2

Expand to an expression which, compiled and evaluated, matches the arguments as if: the descriptor associated to ?type-annotation1 is the type of a formal argument requested by a closure object; the type descriptor associated to ?type-annotation2 is the type of the operand given to a closure object application.

Expand to a quoted symbol:

exact-match

If there is an exact match between the argument’s and operand’s descriptors.

possible-match

If there is a possible match between the argument’s and operand’s descriptors; the operand must be further validated at run–time.

no-match

If there is no match between the argument’s and operand’s descriptors.

Syntax: descriptors-signature-matching ?signature-annotation1 ?signature-annotation2

The arguments signature-annotation must be proper or improper lists of type annotations. Expand to an expression which, compiled and evaluated, matches the arguments as if:

Expand to a quoted symbol:

exact-match

If there is an exact match between the argument’s and operand’s descriptors.

possible-match

If there is a possible match between the argument’s and operand’s descriptors; the operand must be further validated at run–time.

no-match

If there is no match between the argument’s and operand’s descriptors.

Usage examples:

(descriptors-signature-matching
  (<number> <string>)
  (<fixnum> <nestring>))
⇒ exact-match

(descriptors-signature-matching
  (<number> <string>)
  (<fixnum> <top>))
⇒ possible-match

(descriptors-signature-matching
  (<number> <string>)
  (<fixnum> <vector>))
⇒ no-match

Previous: , Up: descriptors   [Contents][Index]