unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: Guile User <guile-user@gnu.org>
Subject: Re: A couple of questions about goops method parameters
Date: Wed, 3 Sep 2014 15:05:30 -0300	[thread overview]
Message-ID: <CAELgYhdoS9Q8v2EVXJauS9WFGiLPT9pGp+Ej5xLxfw5gc00V_g@mail.gmail.com> (raw)
In-Reply-To: <878um0mz10.fsf@elektro.pacujo.net>

[-- Attachment #1: Type: text/plain, Size: 2036 bytes --]

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" <marko@pacujo.net> wrote:

> 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
> > 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 (<point> .x .y)
>      (define (x) .x)
>      (define (y) .y)
>      (make-object #f x y))
>
>    (let ((point (<point> 7 8)))
>      (point #:y))
>    => 8
>
> Marko
>

[-- Attachment #2: Type: text/html, Size: 2753 bytes --]

  reply	other threads:[~2014-09-03 18:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03  2:05 A couple of questions about goops method parameters Carlos Pita
2014-09-03 15:49 ` Carlos Pita
2014-09-03 16:47   ` Marko Rauhamaa
2014-09-03 18:05     ` Carlos Pita [this message]
2014-09-03 16:20 ` Panicz Maciej Godek
2014-09-05  8:32 ` Nala Ginrut
2014-09-05 12:47   ` Carlos Pita
2014-09-05 19:03   ` Panicz Maciej Godek
2014-09-05 19:12     ` David Thompson
2014-09-05 19:35       ` Panicz Maciej Godek
2014-09-05 19:55         ` David Thompson
2014-09-05 20:10         ` Taylan Ulrich Bayirli/Kammer
2014-09-05 20:50           ` David Thompson
2014-09-07 10:33           ` Neil Jerram
2014-09-07 15:27             ` Taylan Ulrich Bayirli/Kammer
2014-09-05 20:10         ` Panicz Maciej Godek
2014-09-05 20:18           ` Taylan Ulrich Bayirli/Kammer
2014-09-05 20:37             ` Panicz Maciej Godek
2014-09-05 20:51               ` Marko Rauhamaa
2014-09-05 21:53                 ` Taylan Ulrich Bayirli/Kammer
2014-09-05 22:26                   ` Marko Rauhamaa
2014-09-05 20:44           ` Marko Rauhamaa
2014-09-05 21:08             ` Panicz Maciej Godek
2014-09-05 22:14               ` Marko Rauhamaa
2014-09-06  8:53                 ` Panicz Maciej Godek
2014-09-06 10:44                   ` Taylan Ulrich Bayirli/Kammer
2014-09-06 11:27                   ` Marko Rauhamaa
2014-09-06 11:54                     ` Taylan Ulrich Bayirli/Kammer
2014-09-06 23:46                     ` Panicz Maciej Godek
2014-09-07  0:20                       ` Marko Rauhamaa
2014-09-07 12:57                         ` Taylan Ulrich Bayirli/Kammer
2014-09-07 13:58                           ` Marko Rauhamaa
2014-09-07 16:46                             ` Taylan Ulrich Bayirli/Kammer
2014-09-07 19:49                               ` Marko Rauhamaa
2014-09-07 23:13                                 ` Taylan Ulrich Bayirli/Kammer
     [not found]           ` <CAPjoZoc7X7s+keog6avP62yvgJyQ3Ma_jomhw6xQq_rK9jnhVw@mail.gmail.com>
2014-09-06 16:57             ` Nala Ginrut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAELgYhdoS9Q8v2EVXJauS9WFGiLPT9pGp+Ej5xLxfw5gc00V_g@mail.gmail.com \
    --to=carlosjosepita@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).