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: Thu, 31 Mar 2016 21:42:04 +0100 (BST) Message-ID: References: <87y492mnjp.fsf@pobox.com> <87io046wp7.fsf@drakenvlieg.flower> <87a8lfx37i.fsf@elektro.pacujo.net> <87shz7vifl.fsf@elektro.pacujo.net> <87egarvb5p.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 1459456956 31886 80.91.229.3 (31 Mar 2016 20:42:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Mar 2016 20:42:36 +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 Thu Mar 31 22:42:23 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 1aljQ6-0005dX-FW for guile-devel@m.gmane.org; Thu, 31 Mar 2016 22:42:22 +0200 Original-Received: from localhost ([::1]:34348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aljQ0-00016x-Qi for guile-devel@m.gmane.org; Thu, 31 Mar 2016 16:42:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aljPw-00015R-LK for guile-devel@gnu.org; Thu, 31 Mar 2016 16:42:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aljPt-0006Wn-DF for guile-devel@gnu.org; Thu, 31 Mar 2016 16:42:12 -0400 Original-Received: from basicbox4.server-home.net ([195.137.212.26]:47798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aljPt-0006Wb-7A; Thu, 31 Mar 2016 16:42:09 -0400 Original-Received: from wedemob.default (unknown [2.27.251.61]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by basicbox4.server-home.net (Postfix) with ESMTPSA id 3C2051530667; Thu, 31 Mar 2016 22:42:05 +0200 (CEST) X-X-Sender: jan@wedemob In-Reply-To: <87egarvb5p.fsf@elektro.pacujo.net> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) Content-ID: 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:18266 gmane.lisp.guile.user:12540 Archived-At: On Thu, 31 Mar 2016, Marko Rauhamaa wrote: > Jan Wedekind : > >> On Wed, 30 Mar 2016, Marko Rauhamaa wrote: >>> GOOPS' has the worst possible object model: objects are seen as mere >>> data records. The concept of a "slot" is an anathema to OOP. >> >> Ok, I have updated the example to use accessor functions instead of >> "slot-ref". > > (get-x) is only a fig leaf for (slot-ref). In general, no user of an > object should think the object holds a piece of information called x. > Instead, you should be interacting with the abstract object . Well, actually (get-x) is a generic as well. I.e. it is polymorphic and does not have to be a simple accessor for a slot. I.e. the accessor syntax is just a shortcut for declaring a generic for accessing a slot separately: (use-modules (oop goops)) (define-class () (x #:init-keyword #:x)) (define-method (get-x (self )) (slot-ref self 'x)) "get-x" can be defined differently for each class and its implementation can be doing something different than accessing a slot. > > Python people call it duck-typing. > > Java, Go et al use interfaces. > > Even C can do opaque structs. > > C++ suffers from "private" data members, and GOOPS strips away even that > thin veil. Here is an example using duck-typing with the generic "get-x": (define-class ()) (define-method (get-x (self )) 123) (define-method (use-duck-typing (x )) (get-x x)) (use-duck-typing (make #:x 3)) ; => 3 (use-duck-typing (make )) ; => 123