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: Conventions when extending apps with Guile...


"Lars J. Aas" <larsa@sim.no> writes:

> 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)...

it certainly _is_ the appropriate forum.  (it's kinda flooded with
development discussions lately, so perhaps a separate public forum for
them is desirable after all).

> 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?

nope, not all of it.  gh_ is a sort of high-level potentially portable 
API, and creating new primitive object types doesn't really generalize 
enough to be portable.

to learn how to create your own object types, see the doc/example-smob 
directory in the distribution or read doc/data-rep.info .

> 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))
>
> [ efficiency concerns snipped ]

before you start inventing your own kind of prototype-based object
system, read the GOOPS tutorial, and consider using GOOPS instead.

-- 
You know better than to trust a strange computer.


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