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

> Tobias Brandt <tob.bra...@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
>

Reply via email to