Previous: syntaxes overloads, Up: syntaxes [Contents][Index]
Vicare allows us to specify special procedures for built–in Scheme types, record–types and label–types; they are:
When applied to a value the type predicate returns #t
if the value
matches the type; otherwise it returns #f
. It is always possible
to use the type predicate with the is-a?
syntax,
see is-a?.
When applied to two values of the same type: the predicate returns
#t
if the values are equal; otherwise it returns #f
.
When applied to two values A and B of the same type, the procedure returns a fixnum:
If A is less than B.
If A is equal to B.
If A is greater than B.
When applied to an instance of the type: compute and return a non–negative fixnum suitable to be used by hashtables.
The following syntactic bindings are exported by the library
(vicare)
.
Return a function that can be used as equality predicate between instances of ?type, which must be a type annotation. If ?type itself has no equality predicate: traverse the hierarchy of parents in search of a predicate. If the hierarchy has no equality predicate: raise a syntax violation.
Return a function that can be used as comparison procedure between instances of ?type, which must be a type annotation. If ?type itself has no comparison procedure: traverse the hierarchy of parents in search of a procedure. If the hierarchy has no comparison procedure: raise a syntax violation.
Return #f
or a function that can be used as hash function for
instances of ?type, which must be a type annotation. If
?type itself has no hash function: traverse the hierarchy of
parents in search of a function. If the hierarchy has no hash function:
raise a syntax violation.
When the expander succeeds in determining the type of ?expr at expand–time: if there is a single return value, expand into an expression that computes and returns a hash value for the return value; otherwise raise a syntax violation.
When the expander fails to determine the type of ?expr at expand–time: expand into an expression that attempts, at run–time, to determine the type of the return value and compute and return a hash value for it.
The hash function used by this syntax is:
fixnum-hash
.
struct-hash
.
hash-function
clause; when no hash function is
specified, record-hash
is used.
Previous: syntaxes overloads, Up: syntaxes [Contents][Index]