guile-user
[Top][All Lists]
Advanced

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

GOOPS and write/display generics


From: Panicz Maciej Godek
Subject: GOOPS and write/display generics
Date: Thu, 20 Dec 2012 03:55:50 +0100

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



reply via email to

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