This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: application init files


   Date: Thu, 29 Jan 1998 18:16:55 -0500
   From: Jim Blandy <jimb@red-bean.com>

   I agree with Tim; I think the real power of Guile is ....

   Providing a better syntax for init files is fine, but Guile is a bit
   of an overkill for that.

Well, I agree with what Tim said too, but I'm now living in an environment
where dozens of programs are storing small amounts of data in lots of
different file formats.  Sometimes the programs just write C structures to a
binary data file, which means their data files are not portable between
hardware architectures.  Sometimes programs write text files, but each one
does so in a different way.  Sometimes humans maintain config files, but again
a different syntax is used for each one.
 
I too agree that the ideal solution for significant programs is to wire up the
internal data structures as Scheme objects so that entensions and init files
can be written in full Scheme, but there are still applications that would
benefit from storing structured data on disk as Scheme-compatible
S-expressions instead of as binary blobs.
 
For instance, I have written servers in C (with Guile embedded) that read
initialization files coded as S-expressions.  Because the init files were the
xmail-sendprint representation of Scheme lists, I could easily write servers in the
Scheme shell (scsh) that read the same init files.  Other Scheme programs
could update the init files and data files easily, since all were encoded as
S-expressions.
 
Another example .... I think Objective-C programs can serialize objects as
ASCII data files.  If these files just happened to be coded as S-expressions,
then Scheme programs could interpret the saved data.
 
Anyway, my thesis is that the Unix world would be a better place if a C
library existed for reading and writing structured data in the form of
parenthesized ASCII text.
 
Getting back to the specific question of initialization files ....  If some
thought were devoted to the question, then one might be able to engineer a
format that would work with both the C library and with a real Scheme
interpreter, such as Guile.  For instance the C library could recognize "set!"
or specific functions applications.  You don't need a full Scheme interpreter
to decode:
 
        (set! *library-directory* "/usr/local/lib/random_server")
        (set-debug-mode #t)
        (set! *search-path* '("~" "~/lib" "/usr/local/lib"))
        (set! *password-table*
              (make-table '(("brown" . "penguin") ("joe" . "wolf"))))
 
The ability to initialize known parameters to booleans, strings, numbers,
lists, and tables would probably suffice for most applications.  If you wanted
to get really fancy, then supporting "if", "begin", "getenv", and
"string-append" would suffice for almost all the rest.
 
                                bob