|
From: | Tobias Brandt |
Subject: | Re: GOOPS constructors |
Date: | Tue, 22 Jul 2014 15:09:34 +0200 |
Tobias Brandt <address@hidden>:
Well, I was trying to find a simple toy example to demonstrate the need,
> 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.
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
[Prev in Thread] | Current Thread | [Next in Thread] |