From: Linas Vepstas <linasvepstas@gmail.com>
To: Thien-Thi Nguyen <ttn@gnuvola.org>
Cc: guile-user@gnu.org
Subject: Re: GNU Guile 1.9.6 released (alpha)
Date: Wed, 16 Dec 2009 09:12:19 -0600 [thread overview]
Message-ID: <3ae3aa420912160712i18da70b7sfddcbbafc56ccdb6@mail.gmail.com> (raw)
In-Reply-To: <87eimv9l4k.fsf@ambire.localdomain>
2009/12/16 Thien-Thi Nguyen <ttn@gnuvola.org>:
> () Linas Vepstas <linasvepstas@gmail.com>
> () Tue, 15 Dec 2009 18:19:21 -0600
>
> I have a new feature request -- it would be useful, in a
> variety of situations, to be able to provide an opaque (void *)
> pointer when calling make_gsubr, and then getting that pointer
> back again whenever the primitive is called.
>
> Presuming i do not misunuderstand your situation, i find object
> properties work well. Instead, of `void *procedure_private_data',
> you have:
>
> (define private-data (make-object-property))
> (define proc ...) ;; or C analog
> (set! (private-data proc) foo)
>
> Am i missing something?
Err ... When my C function is called, how do I go about
getting the void * pointer?
That's a rhetorical question -- I've had to answer it many times.
My solutions to this problem typically consisted of writing
a bunch of extra C code and scheme code that "magically"
wrapped the user's functions with some extra code, salted
away the void * pointer in some scheme structure, and
then pulled it out for the user, when needed. (None of them
used make-object-property, I've never heard of that one
before.)
Having to invent the various parts such as
"(define private-data (make-object-property))" etc. is painful
and cryptic and non-standard, and reinvented differently
for each different project on which I've used guile. And so far,
I've needed this ability on *every* guile project I've worked on.
So I guess I'm saying "this is a common idiom, lets support it"
instead of leaving every user to reinvent it over and over.
--linas
next prev parent reply other threads:[~2009-12-16 15:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-15 23:24 GNU Guile 1.9.6 released (alpha) Ludovic Courtès
2009-12-16 0:19 ` Linas Vepstas
2009-12-16 12:08 ` Thien-Thi Nguyen
2009-12-16 15:12 ` Linas Vepstas [this message]
2009-12-16 16:07 ` Ludovic Courtès
2009-12-16 21:51 ` Linas Vepstas
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=3ae3aa420912160712i18da70b7sfddcbbafc56ccdb6@mail.gmail.com \
--to=linasvepstas@gmail.com \
--cc=guile-user@gnu.org \
--cc=ttn@gnuvola.org \
/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).