This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Conventions when extending apps with Guile...
- To: "Lars J. Aas" <larsa at sim dot no>
- Subject: Re: Conventions when extending apps with Guile...
- From: Michael Livshin <mlivshin at bigfoot dot com>
- Date: 15 Jun 2000 15:14:29 +0200
- Cc: guile at sourceware dot cygnus dot com
- Organization: who? me?
- References: <20000615140424.A13438@sim.no>
"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.