Next: , Up: syntaxes   [Contents][Index]


5.1 Determining the type of expressions

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

Syntax: type-of ?expr

Fully expand the given expression in the current lexical environment and return a structure of type <type-signature> representing the types of the tuple of returned values. The expression is not evaluated, only expanded; this means that the expansion side effects are performed.

Examples:

(type-of (values))
⇒ #[signature ()]

(type-of (values 1 2))
⇒ #[signature (<positive-fixnum> <positive-fixnum>)]

(type-of 123)
⇒ #[signature (<positive-fixnum>)]

(type-of ((lambda ({_ symbol}) 'ciao)))
⇒ #[signature (<symbol>)]

(type-of (+ 1 2))
⇒ #[signature (<exact-integer>)]

(type-of (+ 1.2 2.3))
⇒ #[signature (<flonum>)]

(type-of (list 1 2.3))
⇒ #[signature ((list <positive-fixnum> <positive-flonum>))]

(type-of (condition (make-who-condition 'io)
                    (make-message-condition "ciao")))
⇒ #[signature ((condition &who &message))]
Syntax: type-unique-identifiers ?type-name

Expand into a list of symbols representing the type hierarchy of ?type-name, which must be a syntactic identifier bound to an object type specification.

(type-unique-identifiers <top>)
⇒ (vicare:scheme-type:<top>)

(type-unique-identifiers <string>)
⇒ (vicare:scheme-type:<string>
    vicare:scheme-type:<top>)

(type-unique-identifiers <condition>)
⇒ (vicare:scheme-type:<condition>
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

(type-unique-identifiers <compound-condition>)
⇒ (vicare:scheme-type:<compound-condition>
    vicare:scheme-type:<condition>
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

(type-unique-identifiers &condition)
⇒ (vicare:scheme-type:&condition
    vicare:scheme-type:<condition>
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

(type-unique-identifiers &message)
⇒ (vicare:scheme-type:&message
    vicare:scheme-type:&condition
    vicare:scheme-type:<condition>
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

(internal-body
  (define-struct duo
    (one two)
    (nongenerative yeah))
  (type-unique-identifiers duo))
⇒ (yeah
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

(internal-body
  (define-record-type duo
    (nongenerative duo)
    (fields one two))
  (type-unique-identifiers duo))
⇒ (duo
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

(internal-body
   (define-record-type alpha
     (nongenerative alpha))
   (define-record-type beta
     (parent alpha)
     (nongenerative beta))
   (type-unique-identifiers beta))
⇒ (beta
    alpha
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)