This is the mail archive of the guile@sourceware.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: Examples of embedding guile


Derry Bryson <dbbuile@ta1.reno-onramp.com> writes:

> I am beginning a program which will be a spreadsheet type program
> and I hope to use Guile as the formula/macro language (i.e. where
> the value of each cell would be a guile(lisp) expression).  
> 
> The original idea (brain fart) was to use lisp as a "formula language"
> in a spreadsheet.  I was working with MS Excell and thought "wow, what
> if instead of these stupid formula's, I could just use a lisp
> expression?"  Then, of course, I began imagining what would be
> possible.  Anyway, while considering if I wanted to implement my own
> lisp interpreter (again), I remembered that Guile was a Scheme
> interpreter and intended to be embedded;  this would be perfect!

What a great idea.  I've done a project similar to this for my
employer, and so far it has worked out wonderfully.  I used the Xbae
matrix widget for display, and guile for the cell compilation /
interpretation.  I would be happy to discuss strategy with you along
the way.

I have an explicit compile-time notion for cell formula's which allows
me to strip subscription requests out of the cell formulas, so that
the sheets can respond to real time market data changes.  I just
rewrote the guts of the program to keep all of the main application
data structures in C++, because guile's current GC couldn't keep up
with the very high rate of updates that I was trying to pump through
the interpreter.

Each cell should maintain a raw value, a compiled value (which is a
Scheme thunk), and a cooked value.  The raw value is the string
forumula.  The compiled value is the raw value transformed into a
null-ary scheme procedure which can be evaluated multiple times.  The
cooked value is a string representation of the output of the compiled
value.  Also, each cell needs to keep track of two lists of cell
references; the list of master cells, and the list of slave cells.
Whenever a cell changes it should in turn run the thunks of all it's
slave cells.  When a cell's formula changes, it should first notify
all of it's masters that they do not have it as a slave any longer.
The list of slaves is computed at compile time.

This was my approach to the problem; I hope that this helps.

-russ




--
Don't send a man to do a buoy's job.

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