guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: attempt to make a transparent binding


From: Stephen Compall
Subject: Re: attempt to make a transparent binding
Date: 06 Dec 2004 11:26:30 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

"Oleg A. Paraschenko" <address@hidden> writes:

>   First, the data in memory are big enough, and full instantiation
> of lists wastes resources, especially because I use only small part
> of the data. Instead, I'd like to have lazy instantiation. Let
> "memory->list" returns a special type of pair in which car and cdr
> are instantiated on demand. Is it possible?

This is what Scheme's "promises" are for.  However, I do not know
Guile's promise support, as I've never looked at that part of the
source, and have never needed them myself.

>   The second. Having Scheme data, I'd like to get the origin of this
> data in the C program. Currently I think about mapping from SCMs to
> C structures in C-Guile glue, but I'm afraid this is bad for garbage
> collection.

I can't think of any other way.  If you were using smobs, the natural
thing would be to use a slot for a pointer back to the C struct.
However, you aren't.

As for garbage collection, you could drop the SCMs in a gc protected
guardian, and remove objects you can pull from the guardian every time
you look in your table.

The other solution, if you are really worried about resource usage, is
to eliminate duplication by changing the internal representation of
your program to use SCMs.  Then you could scm_permanent_object a
variable containing a list of current SCMs that may only be live in C.
Further transformation could open up the possibility of writing new
parts of the program in Scheme, or rewriting buggy sections :)

--
Stephen Compall or s11 or sirian

It's not reality or how you perceive things that's important -- it's
what you're taking for it...

halcon interception Serbian Peking world domination espionage SSL
credit card SHA explosion mania infowar embassy ANDVT ASO




reply via email to

[Prev in Thread] Current Thread [Next in Thread]