From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Carlos Pita Newsgroups: gmane.lisp.guile.user Subject: Re: A couple of questions about goops method parameters Date: Wed, 3 Sep 2014 15:05:30 -0300 Message-ID: References: <8761h466wd.fsf@gmail.com> <878um0mz10.fsf@elektro.pacujo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01493fa8e58f3305022d1425 X-Trace: ger.gmane.org 1409767671 32110 80.91.229.3 (3 Sep 2014 18:07:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Sep 2014 18:07:51 +0000 (UTC) To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Sep 03 20:07:46 2014 Return-path: Envelope-to: guile-user@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 1XPEyA-0004Fe-J6 for guile-user@m.gmane.org; Wed, 03 Sep 2014 20:07:46 +0200 Original-Received: from localhost ([::1]:46989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPEy9-0007Ul-RF for guile-user@m.gmane.org; Wed, 03 Sep 2014 14:07:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPEy0-0007Uf-Rm for guile-user@gnu.org; Wed, 03 Sep 2014 14:07:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPExz-0008FF-Lr for guile-user@gnu.org; Wed, 03 Sep 2014 14:07:36 -0400 Original-Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:64377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPEw0-00083J-GQ for guile-user@gnu.org; Wed, 03 Sep 2014 14:05:33 -0400 Original-Received: by mail-lb0-f175.google.com with SMTP id u10so10166004lbd.34 for ; Wed, 03 Sep 2014 11:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=5Zif9U6kV9bh+/Bm/D4ONOGviG66nCMH0lDi9crrPc8=; b=PzaVJQbU0KzP5oIQkjrmXa5PtDpi5Wf7QDJ7nwESY6Oa0oQuR9DCNMJ/adurPa1XKr NQ7ptFGIllMH09uiNNP618Ba6gqlc7EmXYkyKZnZ7eCT471npkV7UFg8i6HOOEJ+ITCP PtnTN1rKdVP14/08UjnuT242KNsPTdIIFuk8in1fLQ0LWQoIjet7VzW7v8FksYvTDSx6 HeQcBMa2Yt1HeZ/mAdOTdgPfDHW40AEBisQ7u9BLwfH2XmIjHDVkcC179Odz2+S7f6AM 6yr+AqJhPj6yXrVzWG5kitAQRXEi68ADZbLVEHEvgDSjqa+TIn/O6koFY03E7dQENe34 kClQ== X-Received: by 10.152.6.133 with SMTP id b5mr43027261laa.16.1409767530924; Wed, 03 Sep 2014 11:05:30 -0700 (PDT) Original-Received: by 10.112.97.129 with HTTP; Wed, 3 Sep 2014 11:05:30 -0700 (PDT) Original-Received: by 10.112.97.129 with HTTP; Wed, 3 Sep 2014 11:05:30 -0700 (PDT) In-Reply-To: <878um0mz10.fsf@elektro.pacujo.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22f X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11453 Archived-At: --089e01493fa8e58f3305022d1425 Content-Type: text/plain; charset=UTF-8 http://www.aiai.ed.ac.uk/~jeff/clos-guide.html and http://permalink.gmane.org/gmane.lisp.cl-pro/24 support the "make as implementation detail" view. Some excerpts: It's often a good idea to define your own constructor functions, rather than call make-instance directly, because you can hide implementation details and don't have to use keyword parameters for everything. For instance, if you wanted the name and age to be required, positional parameters, rather than keyword parameters, you could define (defun make-person (name age) (make-instance 'person :name name :age age)) [Notice how more convolved implementing the same using initialize would be] ------------- In addition to this, you'd use a factory function, rather than having the client call make-instance, to hide the CLOS nature of the type. On Sep 3, 2014 1:47 PM, "Marko Rauhamaa" wrote: > Carlos Pita : > > > So, a question to the experienced lispers here, a question that's not > > specifically guile or goops or scheme related. Is the make (or > > make-instance) way of constructing a new instance usually exposed to > > the final user? Or a factory function, operating at a higher level of > > abstraction, is intended to wrap the lower level, slot-fillig > > oriented, call to make? In this case, a custom initialize method > > implementation should be seen more as a complement to make than as a > > proper constructor/factory. > > I saw the light and left goops behind. I built a simple system: > > * Not slot-centric but method-centric. > > * No classes, only objects. > > IMO, the end result is more schemey than Goops. > > It contains: > > (make-object parentage . methods) > > where > > parentage is #f, an object or a list of objects > > methods contains procedures, or name-procedure pairs > > Example: > > (define ( .x .y) > (define (x) .x) > (define (y) .y) > (make-object #f x y)) > > (let ((point ( 7 8))) > (point #:y)) > => 8 > > Marko > --089e01493fa8e58f3305022d1425 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

http://www.ai= ai.ed.ac.uk/~jeff/clos-guide.html

and

http://perma= link.gmane.org/gmane.lisp.cl-pro/24

support the "make as implementation detail" view.

Some excerpts:

It's often a good idea to define your own constructor functions, rat= her than call make-instance directly, because you can hide implementation d= etails and don't have to use keyword parameters for everything. For ins= tance, if you wanted the name and age to be required, positional parameters= , rather than keyword parameters, you could define

(defun make-person (name age)
=C2=A0 (make-instance 'person :name name :age age))

[Notice how more convolved implementing the same using initialize would = be]
-------------

In addition to this, you'd use a factory function, rather than havin= g
the client call make-instance, to hide the CLOS nature of the type.

On Sep 3, 2014 1:47 PM, "Marko Rauhamaa&quo= t; <marko@pacujo.net> wrote:<= br type=3D"attribution">
Carlos Pita <carlosjosepita@= gmail.com>:

> So, a question to the experienced lispers here, a question that's = not
> specifically guile or goops or scheme related. Is the make (or
> make-instance) way of constructing a new instance usually exposed to > the final user? Or a factory function, operating at a higher level of<= br> > abstraction, is intended to wrap the lower level, slot-fillig
> oriented, call to make? In this case, a custom initialize method
> implementation should be seen more as a complement to make than as a > proper constructor/factory.

I saw the light and left goops behind. I built a simple system:

=C2=A0* Not slot-centric but method-centric.

=C2=A0* No classes, only objects.

IMO, the end result is more schemey than Goops.

It contains:

=C2=A0 =C2=A0 (make-object parentage . methods)

where

=C2=A0 =C2=A0parentage is #f, an object or a list of objects

=C2=A0 =C2=A0methods contains procedures, or name-procedure pairs

Example:

=C2=A0 =C2=A0(define (<point> .x .y)
=C2=A0 =C2=A0 =C2=A0(define (x) .x)
=C2=A0 =C2=A0 =C2=A0(define (y) .y)
=C2=A0 =C2=A0 =C2=A0(make-object #f x y))

=C2=A0 =C2=A0(let ((point (<point> 7 8)))
=C2=A0 =C2=A0 =C2=A0(point #:y))
=C2=A0 =C2=A0=3D> 8

Marko
--089e01493fa8e58f3305022d1425--