Besides, I think that Scheme + OOP has its own flaws. In most OOP
languages, you have this notation object.property or object->method(),
which also allows for chain calls, i.e. object->getChild()->method(),
or -- if you have nested objects -- to use
object.property.propertys_property.

Somewhat related I have seen an interesting project proposal for generics in Racket [1]. The generics use predicate functions instead of classes. E.g.:

    (defmethod add ((x number?) (y number?))
      (+ (x y))

where 'number?' is a function returning '#t' for numbers.

The type hierarchy (specialisation) is declared using 'defsubtype'. E.g.:

    (defsubtype zero? integer?)

This facilitates defining factorial like this:

    (defgeneric fact (n))
    (defmethod fact ((n integer?)) (* n (fact (- n 1))))
    (defmethod fact ((n zero?)) 1)

Regards
Jan

[1] https://fenix.tecnico.ulisboa.pt/downloadFile/3779579671692/project.pdf

Reply via email to