unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GOOPS and write/display generics
@ 2012-12-20  2:55 Panicz Maciej Godek
  2012-12-20 13:47 ` Panicz Maciej Godek
  0 siblings, 1 reply; 2+ messages in thread
From: Panicz Maciej Godek @ 2012-12-20  2:55 UTC (permalink / raw)
  To: guile-user

Hello everyone,
According to section 9.10 of the manual
("GOOPS Object Miscellany"),

"When GOOPS is loaded, `write' and `display' become generic
functions with special methods for printing
[...]
In addition to the cases mentioned, you can of course define `write'
and `display' methods for your own classes, to customize how instances
of those classes are printed."

However, when I try to create a custom display and write method
for my class from within a module (which :use-module (oop goops)),
say
(define-method (display (object <unique-id>) port)
  (display (list (class-name (class-of object)) #[object 'id]) port))

(define-method (write (object <unique-id>) port)
  (write (list (class-name (class-of object)) #[object 'id]) port))

I get the following error:

ERROR: #<procedure display (object #:optional port)> is not a valid
generic function

When I use define-generic before define-method, the problem doesn't disappear,
but it moves elsewhere:
ERROR: No applicable method for #<<generic> display (1)> in call (some
"normal" call to display)

When I'm using this in the main application, ie. outside the module
context, it seems to work fine, though.
Am I doing something wrong? (Because this behavior seems counter-intuitive)

Best regards
M



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

* Re: GOOPS and write/display generics
  2012-12-20  2:55 GOOPS and write/display generics Panicz Maciej Godek
@ 2012-12-20 13:47 ` Panicz Maciej Godek
  0 siblings, 0 replies; 2+ messages in thread
From: Panicz Maciej Godek @ 2012-12-20 13:47 UTC (permalink / raw)
  To: guile-user

OK, I see it now.
The problem was that the module used (rnrs :version (6)),
which defined its own write and display.



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

end of thread, other threads:[~2012-12-20 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-20  2:55 GOOPS and write/display generics Panicz Maciej Godek
2012-12-20 13:47 ` Panicz Maciej Godek

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