"Neil Jerram" wrote:
>Well, the following seems to work ...
>[...]
>In other words, it appears that the args of
>make-procedure-with-setter
>can be generics.

Yes! The following appears to do what I want:

(use-modules (oop goops))

(define-class <my-vec> ()
  (v #:init-keyword #:value))

(define-method (my-vec-setter (v <my-vec>) k)
  (vector-ref (slot-ref v 'v) k))

(define-method (my-vec-getter (v <my-vec>) k value)
  (vector-set! (slot-ref v 'v) k value))

(define elm (make-procedure-with-setter
              my-vec-setter my-vec-getter))

(define-method (display (o <my-vec>) (port <port>))
  (display (slot-ref o 'v) port))

(define v (make <my-vec> #:value #(1 2 3)))

(set! (elm v 1) -9)
(display v)(newline)
(display (elm v 0))(newline)
(display (elm v 1))(newline)
(display (elm v 2))(newline)

Thank You!

My real code does not act upon Guile vectors but upon
a custom class that wraps a custom SMOB. I require the
generic-ness of ELM to let other Guile extensions take
it in an attempt to write math functions 'compatible'
with Guile-GSL.

--
Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"



_______________________________________________
Guile-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/guile-user

Reply via email to