guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to implement 'class methods'


From: Andreas Rottmann
Subject: Re: How to implement 'class methods'
Date: 01 Apr 2002 16:09:47 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Andreas Rottmann <address@hidden> writes:

> Hi!
> 
> I wonder how one could implement 'class methods' (like C++ static
> methods) in GOOPS. I'd like to call them like this:
> 
> (static-method <a-class> "argument")
> 
> where <a-class> would be the class the method belongs to.
> 
> I could use 
> 
> (define-method (a-method (<class> c) args) (do-something))
> 
> but this would get invoked for all calls that pass a class as first
> argument and I'd have to test if the 'right' class is passed and then
> use (next-method) if not.
> 
Found a solution myself :-): create the classes with static methods
each with its own metaclass and specialize the first argument of the
static method on that metaclass. The MOP is really cool!
<jumps-in-excitement/>

Regards, Andy
-- 
Andreas Rottmann         | address@hidden        | address@hidden | 
address@hidden
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62



reply via email to

[Prev in Thread] Current Thread [Next in Thread]