[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: namespaces, goops, etc.
From: |
Michael Livshin |
Subject: |
Re: namespaces, goops, etc. |
Date: |
03 Nov 2000 22:43:01 +0200 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (20 Minutes to Nikko) |
"Lars J. Aas" <address@hidden> writes:
> On Fri, Nov 03, 2000 at 08:13:19PM +0200, Michael Livshin wrote:
> : "Lars J. Aas" <address@hidden> writes:
> : > Another thing I've noticed is that generic goops methods has to be defined
> : > in the toplevel namespace. Was there a reason for this design decision,
> other
> : > than perhaps making the goops module easier to implement (global
> variables and
> : > stuff?)? Just wondering - it's not a feature I miss or anything,
> although I
> : > can imagine it could be useful with local generic methods in certain
> : > circumstances...
> :
> : this design decision surely looks right to me. except you are
> : speaking specifically about `define-method', because you can add and
> : remove methods anytime, by more "imperative" means.
>
> I'm not sure I understand exactly how/what you mean.
>
> Can I for instance create a generic function (with polymorphism) that I can
> store
> in an alist and retrieve later to execute with some arguments? I actually
> found out
> I could really use that a few minutes ago...
oops, I took your words at face value without checking. but I see
your problem now.
`define-method' is a magic syntax. the magic is that when the generic
function you specialize doesn't already exist, it's defined in place.
for some hairy implementational reasons the code emitted by
`define-method' for non-existing generic is not legal for placing in
any place other then top level.
so, this works:
(define-generic foo)
(define (hiho)
;; the generic already exists, so this works:
(define-method foo ((x <top>)) x))
this doesn't work:
(define (hiho)
;; if no generic named "foo" exists by the time we are called for
;; the first time, there's trouble:
(define-method foo ((x <top>) x)))
but the following works, but has different semantics (the semantics
you actually asked for):
(define (hiho)
;; define the generic locally:
(define-generic foo)
;; now happily specialize it:
(define-method foo ((x <top>) x)))
--
May all your PUSHes be POPped.
- namespaces, goops, etc., Lars J. Aas, 2000/11/03
- Re: namespaces, goops, etc., thi, 2000/11/03
- Re: namespaces, goops, etc., Michael Livshin, 2000/11/03
- Re: namespaces, goops, etc., Lars J. Aas, 2000/11/03
- Re: namespaces, goops, etc.,
Michael Livshin <=
- Re: namespaces, goops, etc., Lars J. Aas, 2000/11/03
- Re: namespaces, goops, etc., Michael Livshin, 2000/11/03
- Re: namespaces, goops, etc., Lars J. Aas, 2000/11/03
- Re: namespaces, goops, etc., Lars J. Aas, 2000/11/03
- Re: namespaces, goops, etc., Mikael Djurfeldt, 2000/11/06
- Re: namespaces, goops, etc., Michael Livshin, 2000/11/07
- Re: namespaces, goops, etc., Mikael Djurfeldt, 2000/11/08
- Re: namespaces, goops, etc., Mikael Djurfeldt, 2000/11/06
Re: namespaces, goops, etc., Mikael Djurfeldt, 2000/11/06
Re: namespaces, goops, etc., Mikael Djurfeldt, 2000/11/06