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


2.4 Relations between type signatures

The following syntactic bindings are exported by the library (vicare expander).

Syntax: type-signature-super-and-sub? ?signature1 ?signature2

Expand to a boolean constant: #t if ?signature1 is a super–signature of ?signature2; otherwise #f. The arguments ?signature must be proper or improper lists of type annotations.

(type-signature-super-and-sub? (<number>) (<fixnum>))  ⇒ #t
(type-signature-super-and-sub? (<number>) (<string>))  ⇒ #f

(expansion-of
  (type-signature-super-and-sub? (<number>) (<fixnum>))
⇒ (quote #t)

(expansion-of
  (type-signature-super-and-sub? (<number>) (<string>))
⇒ (quote #f)

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

(type-signature-super-and-sub? (<number> <number>)
                               (<fixnum> <fixnum>))
⇒ #t
(type-signature-super-and-sub? (<fixnum> <fixnum>)
                               (<number> <number>))
⇒ #f

(type-signature-super-and-sub? (<number> <number> . <list>)
                               (<fixnum> <real>   . <list>))
⇒ #t
Syntax: type-signature-matching ?args-signature ?rands-signature

Match the two signatures as if: ?args-signature is the type signature of the arguments requested by a closure object; ?rands-signature is the type signature of the operands given to a closure object application.

Expand to a quoted symbol:

exact-match

If there is an exact match between the arguments’ and operands’ signatures.

possible-match

If there is a possible match between the arguments’ and operands’ signatures; the operands must be further validated at run–time.

no-match

If there is no match between the arguments’ and operands’ signatures.

(type-signature-matching (<top>) (<void>))
⇒ no-match

(type-signature-matching (<void>) (<top>))
⇒ no-match

(type-signature-matching (<top>) (<fixnum>))
⇒ exact-match

(type-signature-matching (<fixnum>) (<positive-fixnum>))
⇒ exact-match

(type-signature-matching (<fixnum>) (<top>))
⇒ possible-match
Syntax: type-signature-common-ancestor ?signature1 ?signature2

Expand to a syntax object representing the type signature that is the common ancestor of ?signature1 and ?signature2.

(type-signature-common-ancestor (<fixnum> <fixnum>)
                                (<flonum> <bignum>))
⇒ #'(<real> <exact-integer>)

(type-signature-common-ancestor (<fixnum> <fixnum> <string>)
                                (<flonum> <bignum>)
⇒ #'(<real> <exact-integer> . <list>)

(type-signature-common-ancestor (<fixnum> <fixnum>)
                                (<flonum> <bignum> <string>)
⇒ #'(<real> <exact-integer> . <list>)
Syntax: type-signature-union ?type-signature

Compute the union between the given type signatures and expand to a quoted symbolic expression representing the result. Each ?type-signature argument must be a symbolic expression representing a type signature.

(type-signature-union)
⇒ <list>

(type-signature-union (<fixnum>) (<exact-integer>))
⇒ (<exact-integer>)

;;If a component is "<void>" the whole union between type
;;annotations becomes "<void>".
(type-signature-union (<fixnum>) (<void>))
⇒ (<void>)

;;If there are both "<true>" and "<false>": they are
;;replaced with a single "<boolean>".
(type-signature-union (<true>) (<false>))
⇒ (<boolean>)

(type-signature-union (<fixnum> <string> <vector>)
                      (<fixnum> <string> <vector>))
⇒ (<fixnum> <string> <vector>)

(type-signature-union (<fixnum> <string> <vector>)
                      (<positive-fixnum> <string> <vector>))
⇒ (<fixnum> <string> <vector>)

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