[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Guile 1.9.6 released (alpha)
From: |
Linas Vepstas |
Subject: |
Re: GNU Guile 1.9.6 released (alpha) |
Date: |
Wed, 16 Dec 2009 09:12:19 -0600 |
2009/12/16 Thien-Thi Nguyen <address@hidden>:
> () Linas Vepstas <address@hidden>
> () 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