[Top][All Lists]

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

Re: [GUILE] Clubie question re loading data.

From: Westley A Sherman
Subject: Re: [GUILE] Clubie question re loading data.
Date: Thu, 25 Jan 2001 17:23:16 -0500 (EST)

On Thu, 25 Jan 2001, Bobby D. Bryant wrote:

> I would like to store application configuration data as a Scheme list
> and load it into my program at run time.  The best I can figure out so
> far is to create a .scm file something like this...
> ;; Configuration data:
> (define program-data
>     '((size 100 100)
>       (color blue)
>       (more stuff like that below)
>      )
> )

I've been wondering about using a Scheme like syntax for configuration
files as well. What I had in mind, though, was automatically converting
the the Scheme expression(s) into some sort of C data structures.
For example, one would read data in this form:

(polymer "protein"
         (monomer "ALA"
                  (atom " CA "  0)
                  (atom " N  " +1))
         (monomer "GLY"
                  (atom " CA "  0)
                  (atom " O  " -1)))

into a data structure of this form:

typedef struct {
    char name[5];
    int charge;
} Atom;
typedef struct {
    char name[4];
    Atom atoms[];
} Monomer;
typedef struct {
    char * name;
    Monomer monomers[];
} Polymer;
Polymer polymers[];

One possibility might be to have each of the keywords "polymer", "monomer"
and "atom" be scheme functions that returned the associated C data
structure. For large data/configuration files this might be pretty slow
and memory management could be a pain. Also, ideally one wouldn't have to
write the scheme functions by hand. One would simply specify the data
structures and the scheme functions would be generated automatically. I
guess that's the kind of things that lex and yacc are designed for but
then they don't provide the ability to include arbitrary scheme
expressions in one's configuration file.

Anyway, it was too big a project for me but I'll be interested to hear
what other people have done.


reply via email to

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