[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GOOPS constructors
From: |
Marko Rauhamaa |
Subject: |
Re: GOOPS constructors |
Date: |
Tue, 22 Jul 2014 16:03:43 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Tobias Brandt <address@hidden>:
> 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