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


5.4 Predicate syntaxes

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

Syntax: is-a? ?expr ?type
Syntax: is-a? _ ?type
Auxiliary Syntax: _

Expand to an expression which, when evaluated, returns #t if ?expr evaluates to a value of type ?type. ?expr can be any expression returning a single value.

When _ is used as first argument: the syntax evaluates to a predicate function.

(define-record-type duo
  (fields one two))

(is-a? (new duo 1 2) two)       ⇒ #t

((is-a? _ duo) (new duo 1 2))   ⇒ #t

(is-a? 123 duo)                 ⇒ #f

(is-a? '(1 2 3) (list <fixnum> <exact-integer> <number>))
⇒ #t