[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: anyone define port types?

From: Jan Wedekind
Subject: Re: anyone define port types?
Date: Wed, 30 Mar 2016 22:01:41 +0100 (BST)
User-agent: Alpine 2.11 (DEB 23 2013-08-11)

On Wed, 30 Mar 2016, Marko Rauhamaa wrote:

Jan Wedekind <address@hidden>:

GOOPS supports "open" classes and multiple-dispatch. E.g. you can extend
the "write" method to control how an object is displayed within the
Guile REPL [1]. Another interesting approach are multi-methods in
Clojure which don't even require explicit types for dispatching.


Your example demonstrates my problem with GOOPS: you are redefining
(display) by penetrating the black box with (slot-ref). What would
happen to your method if I changed the implementation of <a> so it
no longer has the slot x, even virtually.

GOOPS' has the worst possible object model: objects are seen as mere
data records. The concept of a "slot" is an anathema to OOP.

Think of a UNIX file. You access it through open(2), write(2), read(2),
close(2) and so on. You don't know and you shouldn't care how the file
contents are organized on the disk (if there is a disk!). GOOPS would
like to abandon the system calls and just expose the bytes (slots) on
the disk. Then, GOOPS lets you define any kind of system calls you see

Ok, I have updated the example to use accessor functions instead of "slot-ref". But yes, a GOOPS generic only dispatches on types where instances in turn need to define slots (attributes). That's why I pointed out Clojure multimethods which uses a more flexible dispatch mechanism (using an inheritance graph and dispatching on the return value of an arbitrary function).

GOOPS (as well as Clojure multimethods) provide "open" classes and multiple-dispatch. Two things which I can really recommend to play with.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]