From: "Marco Maggi" <marco.maggi-ipsu@poste.it>
Subject: Re: accessor with 2/3 parameters
Date: Sun, 20 Aug 2006 08:08:02 +0200 [thread overview]
Message-ID: <J4A91E$3F4690A1F20F950EF8AE4865CCD62B95@poste.it> (raw)
"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
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
next reply other threads:[~2006-08-20 6:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-20 6:08 Marco Maggi [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-08-18 18:35 accessor with 2/3 parameters Marco Maggi
2006-08-19 10:29 ` Neil Jerram
2006-08-19 23:17 ` Neil Jerram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='J4A91E$3F4690A1F20F950EF8AE4865CCD62B95@poste.it' \
--to=marco.maggi-ipsu@poste.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).