From: Andreas Rottmann <a.rottmann@gmx.at>
Subject: Re: Class methods in GOOPS
Date: Sun, 12 Oct 2003 14:16:26 +0200 [thread overview]
Message-ID: <87he2e4pnp.fsf@alice.rotty.yi.org> (raw)
In-Reply-To: <20031009161749.GG25684@lark> (Andy Wingo's message of "Thu, 9 Oct 2003 18:17:49 +0200")
Andy Wingo <wingo@pobox.com> writes:
> Hello,
>
> It seems there are no class methods in GOOPS. Is this a deliberate
> omission, or were they just overlooked? If this is old hat, please point
> me to a URL somewhere, I couldn't find any.
>
What I did to work around this was to make the classes that should
have "class methods" (static methods in C++) have a metaclass, then
you can specialize methods on the metaclass; e.g:
(use-modules (oop goops))
(define-class <A-meta> ())
(define-class <B-meta> ())
(define-class <A> ()
#:metaclass <A-meta>)
(define-class <B> ()
#:metaclass <B-meta>)
(define-method (class-method (class <A-meta>) (msg <string>))
(format #t "I am a static method of class A: ~S\n" msg))
(define-method (class-method (class <B-meta>) (msg <string>))
(format #t "I am a static method of class B: ~S\n" msg))
(class-method <A> "Hello world")
(class-method <B> "Hello world")
> Thanks for any insight,
>
HTH, Andy.
Regards, Andy
--
Andreas Rottmann | Rotty@ICQ | 118634484@ICQ | a.rottmann@gmx.at
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
Latein ist das humanoide Äquivalent zu Fortran.
-- Alexander Bartolich in at.linux
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
prev parent reply other threads:[~2003-10-12 12:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-09 16:17 Class methods in GOOPS Andy Wingo
2003-10-12 12:16 ` Andreas Rottmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87he2e4pnp.fsf@alice.rotty.yi.org \
--to=a.rottmann@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).