[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exposing C struct contents in Scheme
From: |
Dale P. Smith |
Subject: |
Re: exposing C struct contents in Scheme |
Date: |
Tue, 22 Apr 2003 10:22:03 -0400 |
On Tue, 22 Apr 2003 14:56:13 +0200
Pascal Haakmat <address@hidden> wrote:
> Most importantly, I am unsure how to represent/modify my application's
> struct's from guile. The guile documentation on SMOBifying structs
> made the initial work quite easy, but it doesn't really address the
> question of how to deal with the information inside the structs. As
> far as I can see, there are 3 methods to deal with that:
>
> 1. Write getter/setter functions for every property in the struct.
> 2. Write a generic getter/setter function that takes a string argument
> denoting the property to get/set.
> 3. Use some kind of Scheme type (records? structs? objects? I'm
> confused about these and from what little examples I have seen the
> Scheme syntax to manipulate these types seems rather grotty).
>
> The first method has the drawback that it provides no means of
> enumerating all possible properties. The second method might be slow
> for large numbers of properties. The third method has the drawback
> that it probably requires huge changes in my program, and I guess I'd
> also be relinquishing a lot of control, which I'm not quite prepared
> to do until I become more familiar with guile/Scheme.
>
> I'm leaning towards the second method, but would prefer something more
> Scheme-native (a la method 3) if only I knew how to get started
> (without having to make huge changes). So I'd appreciate some examples
> on how I might do that (and enumerate the properties in a
> record/struct/object), or pointers to examples.
I had a similar problem with mod-guile. I ended up writing some C
macros that create all the getter/setter routines I needed. See
http://savannah.nongnu.org/cgi-bin/viewcvs/*checkout*/mod-guile/mod-guile/mod_guile.c?rev=1.3&content-type=text/plain
-Dale
--
Dale P. Smith
Senior Systems Consultant, | Treasurer,
Altus Technologies Corporation | Cleveland Linux Users Group
dsmith at altustech dot com | http://cleveland.lug.net
440-746-9000 x239 |