From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan Wedekind Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: anyone define port types? Date: Wed, 30 Mar 2016 22:01:41 +0100 (BST) Message-ID: References: <87y492mnjp.fsf@pobox.com> <87io046wp7.fsf@drakenvlieg.flower> <87a8lfx37i.fsf@elektro.pacujo.net> <87shz7vifl.fsf@elektro.pacujo.net> Reply-To: Jan Wedekind NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Trace: ger.gmane.org 1459371730 11980 80.91.229.3 (30 Mar 2016 21:02:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Mar 2016 21:02:10 +0000 (UTC) Cc: Andy Wingo , "guile-user@gnu.org" , guile-devel To: Marko Rauhamaa Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Mar 30 23:02:03 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1alNFZ-0003Ks-5z for guile-devel@m.gmane.org; Wed, 30 Mar 2016 23:02:01 +0200 Original-Received: from localhost ([::1]:56783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alNFV-0005zA-Do for guile-devel@m.gmane.org; Wed, 30 Mar 2016 17:01:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alNFM-0005z3-2w for guile-devel@gnu.org; Wed, 30 Mar 2016 17:01:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alNFJ-0002vo-Cu for guile-devel@gnu.org; Wed, 30 Mar 2016 17:01:48 -0400 Original-Received: from basicbox4.server-home.net ([195.137.212.26]:36523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alNFJ-0002vR-6g; Wed, 30 Mar 2016 17:01:45 -0400 Original-Received: from wedemob.default (unknown [95.150.201.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by basicbox4.server-home.net (Postfix) with ESMTPSA id AC6811530663; Wed, 30 Mar 2016 23:01:42 +0200 (CEST) X-X-Sender: jan@wedemob In-Reply-To: <87shz7vifl.fsf@elektro.pacujo.net> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 195.137.212.26 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:18260 gmane.lisp.guile.user:12534 Archived-At: On Wed, 30 Mar 2016, Marko Rauhamaa wrote: > Jan Wedekind : > >> 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. >> >> [1] http://wedesoft.de/oop-with-goops.html > > 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 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 > fit. > > > Marko 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.