unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Tobias Brandt <tob.brandt@googlemail.com>
To: Marko Rauhamaa <marko@pacujo.net>
Cc: "guile-user@gnu.org" <guile-user@gnu.org>
Subject: Re: GOOPS constructors
Date: Tue, 22 Jul 2014 15:09:34 +0200	[thread overview]
Message-ID: <CAOOWqiqCqLeU1AB9ctcYpscD6KN5mv4DHX8x+d0=+yr7LAjuwQ@mail.gmail.com> (raw)
In-Reply-To: <877g35o89c.fsf@elektro.pacujo.net>

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

I don't have access to guile currently, so I can't try this. But I think
you can just pass path, code, and fs to next-method.
They should eventually end up in the default initialize.

(define-method (initialize (@ <file-error>) args)
  (let-keywords
   args #f ((path #f) (code #f) (fs #f))
   (next-method @ (list #:msg (format #f "File error in ~S (~S)" path code)
#:path path #:code code #:fs fs))))


On 22 July 2014 15:03, Marko Rauhamaa <marko@pacujo.net> wrote:

> Tobias Brandt <tob.brandt@googlemail.com>:
>
> > Couldn't just define <square> like this:
> >
> > (define-class <square> (<rectangle>))
> >
> > then define a side method:
> >
> > (define-method (side (@ <square>)) (slot-ref @ 'height))
> >
> > This way, you're not storing the same information twice.
>
> Well, I was trying to find a simple toy example to demonstrate the need,
> but maybe I'll need to find a more compelling one.
>
> How about:
>
> ========================================================================
> (define-class <error> ()
>   (msg #:getter msg #:init-keyword #:msg))
>
> (define-class <file-error> (<error>)
>   (path #:getter path #:init-keyword #:path)
>   (code #:getter code #:init-keyword #:code)
>   (fs #:getter fs #:init-keyword #:fs))
>
> (define-method (initialize (@ <file-error>) args)
>   (let-keywords
>    args #f ((path #f) (code #f) (fs #f))
>    (next-method @ (list #:msg (format #f "File error in ~S (~S)" path
> code)))))
> ========================================================================
>
> How do I now write the getters for path, code and fs?
>
>
> Marko
>

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

  reply	other threads:[~2014-07-22 13:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22 12:18 GOOPS constructors Marko Rauhamaa
2014-07-22 12:22 ` Tobias Brandt
2014-07-22 13:03   ` Marko Rauhamaa
2014-07-22 13:09     ` Tobias Brandt [this message]
2014-07-22 13:15       ` Marko Rauhamaa
2014-07-23 15:02     ` Barry Fishman
2014-07-23 17:42       ` Marko Rauhamaa
     [not found]         ` <m3lhri21kk.fsf@barry_fishman.acm.org>
2014-07-25 10:26           ` Marko Rauhamaa

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='CAOOWqiqCqLeU1AB9ctcYpscD6KN5mv4DHX8x+d0=+yr7LAjuwQ@mail.gmail.com' \
    --to=tob.brandt@googlemail.com \
    --cc=guile-user@gnu.org \
    --cc=marko@pacujo.net \
    /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).