[Top][All Lists]

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

Re: display/write generics in GOOPS

From: Panicz Maciej Godek
Subject: Re: display/write generics in GOOPS
Date: Fri, 29 Nov 2013 09:07:53 +0100

2013/11/29 <address@hidden>

Are `display' and `write' supposed to get overwritten with generic
functions when GOOPS is loaded? The manual says so, but when I try it in
2.0.9 and the latest build on master, it doesn't seem to happen:

scheme@(guile-user)> (use-modules (oop goops))
scheme@(guile-user)> display
$2 = #<procedure display (_ #:optional _)>

(define-method (display ...) ...) doesn't give me any errors, but
doesn't seem to affect the result of actually calling display on
anything. Am I missing something?

It is important how you define your method.
In order to work properly, it needs exactly two
arguments, the first being an object of given type,
and the second (typeless) -- a port.
So the following code should work:
(use-modules (oop goops))

(define-class <A> ()
  (a #:init-value 5))

(define-method (display (a <A>) port)
  (display "Object A" port))

(define a (make <A>))

(display a)
;; should display "Object A" (and it does so on my system)


reply via email to

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