guile-user
[Top][All Lists]
Advanced

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

libguile woes


From: Kyle Cronan
Subject: libguile woes
Date: Sat, 10 Feb 2001 20:03:58 +0000 (/etc/localtime)

Hello all,

I am designing a billing system (primarily in C) that I would like to
extend by using libguile as an interpreted language for generating
reports.  The first thing I have started implementing is the scheme
procedure (db-get (<field list>) (<constraint list>) (<parameter list>))
which constructs an SQL query, executes it, and returns the results in a
list.

Because I do not want to require that the people writing these reports
know all about how to do a join in SQL, I wrote some C code that attempts
to grok the topology of the tables in my billing system.  It shouldn't
really be necessary for me to describe it in detail here, because it
doesn't really relate to my problem, but basically it tries to find the
shortest path including two or more tables given structures that describe
the links between the various tables.  I have attached the source with
this message.

I have three questions related to my use of guile:

1.  I am (unavoidably) required to use Sun C compiler version 4.2.  Can
anyone guess why a minimal program linked with libguile and calling only
gh_enter() would immediately fail with "ERROR: Stack overflow"?  This only
happens when I use the c compiler (cc), and goes away if I use the c++
compiler (CC).  Not such a big deal, but it's annoying.

2.  In the db_get function in the included code, is there a simpler way of
getting the three lists my procedure accepts?  Perhaps using just the gh_ 
interface?  I stole the code I'm now using from the author of squile,
Jorgen Schaefer... Thanks Jorgen!

3.  My main problem:  When I compile and run this program, and pass it
something like, (Only the parts in the strings before the period matter.)

(db-get '("plans.bleh" "rates.bleh"))

the first few times it correctly identifies the path from the plans table
to the rates table.  But eventually it stops working, and will output
nothing at all when I call db-get.  After several times it goes back to
working.  It's quite random.  If you uncomment the part in main which
bypasses gh_enter, it works perfectly.

I'm assuming (3) has something to do with garbage collection, but I wasn't
able to figure it out.  Do I have to call scm_protect_object on something?

Finally, if anyone is interested, take a look at the recursive find_path
function, and walk_topology which calls it.  If you think that this code
would be significantly more beautiful in scheme, I'll give it a shot, as
I'm just starting with scheme and it might be a nice exercise.

Thanks a lot for your help.

Kyle Cronan
<address@hidden>

Attachment: fields.c
Description: Text document


reply via email to

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