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]

Conventions when extending apps with Guile...


  Hi guys,

I've started using guile (just guile-core) as a backend to a simple
drawing program I'm writing, and there are a couple of issues I'm
wondering about.  This isn't about guile development, merely guile usage;
I hope this is an appropriate forum anyway (please bear with me if it
isn't)...

I'm creating "objects" in C-space that are passed back to guile.  Right
now I just enumerate the objects and return the integer number of the
object to Guile, forcing me to maintain a table of objects in C-space.
What I would like to do instead is to create a new data type and return
a pointer to the object data instead, and be able to use Guile's
memory management to know when the object is no longer referenced and
should be freed.  Is that possible using the gh_* interface?

Another thing I'm wondering about is more of a convention issue.  Instead
of objects, the objects are defined by lambda-functions that invoke a
dispatcher function with the object id as the first argument.  I can for
instance write this in the init script:

  (define window1 (app 'new-window))
  (window1 'set-size 500 400)
  (window1 'show)

The (app 'new-window) invocation creates a window, and returns:

  (lambda (cmd . args) (app-window-dispatch <window-id> cmd args))

I'm concerned with the efficiency of using quoted symbols for the
dispatcher (forces me to use a sequence of strcmp()s or a hash-table
of some sort.  guile-gtk (or was it guile-tk?) uses a ":symbol"
convention for naming arguments - is that a widely used convention?
Is it just for _optional_ arguments or used for all arguments?
(I'm new to *using* scheme, if you didn't guess).  I haven't
investigated the matter, but I imagine that the ":<symbol>" keywords
are enumerated to integers or something, which would be much
more efficient to use in a switch() in the C dispatcher, or am I
way off?  If I were to use such a scheme (insert the 'no pun'-phrase
here if you want) what's the most efficient way to get the symbols
defined?  I'd like to avoid setting them up through gh_eval_str()
calls...

Thanks in advance,

  Lars J

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