unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Class methods in GOOPS
@ 2003-10-09 16:17 Andy Wingo
  2003-10-12 12:16 ` Andreas Rottmann
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Wingo @ 2003-10-09 16:17 UTC (permalink / raw)


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.

Thanks for any insight,

wingo.




_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Class methods in GOOPS
  2003-10-09 16:17 Class methods in GOOPS Andy Wingo
@ 2003-10-12 12:16 ` Andreas Rottmann
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Rottmann @ 2003-10-12 12:16 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-12 12:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-09 16:17 Class methods in GOOPS Andy Wingo
2003-10-12 12:16 ` Andreas Rottmann

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).