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: Guile Plug-In for Gnumeric


Mark Probst <schani@unix.cslab.tuwien.ac.at> writes:

> second, are you sure the following function is ok?
> 
> > static scm_sizet
> > cell_sweep(SCM obj)
> > {
> >   cell->obj_init_p = 0;
> >   cell->obj = SCM_UNDEFINED;  
> >   cell_decrease_refcount(cell);  /* this will only happen when the scheme */
> >                                  /* object's lifetime ends */
> > }

Well, I do some stuff like this in production code.  Does that count?
Obviously the code I wrote is vaporware, but the idea is solid.

> > Does my code above provide a potential solution?  I think it does,
> > unless I don't quite understand your question.
> 
> the latter is the case :-).

I'm glad.

> the problem is that it is possible to refer to cells by absolute
> and by relative position. the latter makes it necessary to have some
> refernence point (the current cell). i don't want to introduce the
> notion of a current cell, though, neither do i want to pass around
> a CellRef through all functions just in case somebody wants to eval
> a relative CellRef.

Whenever you call out to Scheme, I would recommend supplying the
CellRef as an argument to the Scheme procedure.  It's a bit tedious at
times, but I've tried it both ways, and this one works much better as
the program gets bigger.  If you need an explicit notion of the
current cell, specify that in Scheme; don't try to code this part in
C.

-russ


in scheme:
----------
(define *current-cell* #f)

(define (gnumeric:cell-changed-callout cell)
  (fluid-let ((*current-cell* cell))
    (stuff-relying-on-*current-cell*)))


in C:
-----
static SCM
make_callout(char *callout, SCM ls)
{
    SCM proc;
    proc = SCM_CDR(scm_intern0(callout));
    return scm_apply(proc, ls, SCM_EOL);
}

make_callout("gnumeric:cell-changed-callout",
             scm_listify(cell_box(cell),
                         SCM_UNDEFINED));

--
"There is hardly anything in the world that some man cannot make a
little worse and sell a little cheaper, and the people who consider
price only are this man's lawful prey."  
             -- John Ruskin