Ramana wrote:
> Can the record printer in Ikarus be customized (e.g. only
> print a certain field, or print field names)?
>
> Can we extend equal? to new records (like "deriving Eq" in
> Haskell)?
If you mean changing the behaviour of a function in all the
program and all the imported libraries, the answer is no to
both (unless something changed in the latest months).
Scheme by itself has no function overload/multimethod
dispatching.
What you can do is to write a library with modified
features (for example a customised EQUAL?), then import it
in your program and other libraries using the IMPORT
features to select the appropriate versions of the bindings.
For example the library:
(library (my-cmp)
(export my-equal?)
(import (rnrs))
(define (my-equal? a b)
(display 'we-are-here)
(newline)
(cond
((and (number? a)
(number? b))
(= a b))
(else (equal? a b)))))
defines a different equal function, and it can be imported
in a program with:
(import (except (rnrs) equal?)
(rename (my-cmp)
(my-equal? equal?)))
(display (equal? 123 456))
(newline)
(display (equal? 123 123))
(newline)
(display (equal? 'alpha 'beta))
(newline)
(display (equal? 'alpha 'alpha))
(newline)
You can also use a CLOS-like object system that uses the
same mechanism to provide "overloaded functions".
> What about in R6RS?
The same.
HTH
--
Marco Maggi