guile-user
[Top][All Lists]
Advanced

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

exposing C struct contents in Scheme


From: Pascal Haakmat
Subject: exposing C struct contents in Scheme
Date: Tue, 22 Apr 2003 14:56:13 +0200
User-agent: Mutt/1.2.5i

Hello,

I'm considering the use of guile to script my application. Since I'm
new to guile (and Scheme/LISPish languages in general), I want to take
things slowly and start out using a very limited subset of language
features. I'm still not decided whether I like Scheme and/or whether
it's the best tool for the job, but a lot of that uncertainty stems
from the fact that I have little intuition on how to do things in the
language or what the proper idioms are. So I'm looking for some
advice.

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.

Sorry for the long mail on what is probably a FAQ, but I couldn't find
a lot of info on the mailing lists, and I barely understood what I did
find. Hopefully some of you can find the time to help me on my way.

Thanks,
Pascal.




reply via email to

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