2013/11/29 <[email protected]> > > 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 _)> > scheme@(guile-user)> > > (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) Regards, M.
