[Ecls-list] Embedding ECL (Newbie)

Geoff Cant geoff at catalyst.net.nz
Sun Jan 22 18:36:06 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aha! It turns out the eval thing is working mostly OK. If I eval  
(common-lisp:+ 1 1) instead, it works fine and returns the expected  
"2". However anything that has an error invokes the debugger which  
tries to do std IO and explodes recursively.

It seems the safe eval (which I thought was supposed to swallow all  
errors) isn't trapping errors as I expected - is there any way I can  
make it return nil instead of trying to invoke the debugger? Or can I  
inhibit the IO explosions by redirecting stdin to a string stream?

Thanks muchly,
- - --Geoff Cant (Catalyst IT)


On 2006-01-23, at 14:36 , Geoff Cant wrote:

> Hi David, the first error after the eval seems to be:
> THROW: The catch #:G1 is undefined.
> Broken at COMMON-LISP:EVAL.
> QUAKE> Read or write operation to stream #<input stream "stdin">  
> signaled an error.
> Explanation: Resource temporarily unavailable.
> Broken at COMMON-LISP:ERROR.
>
> ECL seems to be trying to invoke the debugger which requires reading
> stdin, which fails and so it tries to call the debugger.
>
> Is there anything obvious that would cause the "THROW: The catch #:G1
> is undefined" error? Do I need to pass an environment to eval?
>
> Thanks heaps,
> --Geoff Cant
>
> David Creelman <dave at geko.net.au> writes:
>
> > Hi Geoff,
> >
> > Embedding in Quake is interesting. Sounds like fun.
> >
> > A few things.
> >
> > There are a few inlines there instead of static. I think it  
> should be
> > static on those ?
> >
> > my_c_string_to_object is defined, but it's not used anywhere.  
> Maybe that
> > will show up some errors.
> >
> > I think nargs should be 3, not 4. It's a count of the args not  
> including
> > the count itself.
> >
> > Also, apparently pointing to obj->string.self is not always safe,
> > because ECL strings are resizable and not guaranteed to be null
> > terminated. Try using ecl_make_null_terminated_string (from  
> memory ?) or
> > write a function that wraps the following
> >
> > strncpy(obj->string.self, dest, obj->string.fillp);
> >
> > Also, there's a recurring malloc, free in there. Is it possible to
> > declare it as char lisp_code[200] and not have to worry about the
> > overhead of malloc/free ? This way lisp_code gets looked after on  
> the
> > stack. ECL will make a copy of the string, so you'll be okay  
> (works for
> > me).
> >
> > Cheers
> > DC
> >
> >
> > On Mon, 2006-01-23 at 12:03 +1300, Geoff Cant wrote:
> >> Hi there, I'm new to embedding ECL into things and am having  
> trouble
> >> with ecl and Quake 1.
> >>
> >> I'm trying to embed ecl into the QuakeWorld client. I've got as  
> far as
> >> booting CL and converting strings to cl_objects and back again via
> >> format, but can't figure out how to actually get eval/funcall to  
> work
> >> properly. At the moment, they crash the application with tens of
> >> thousands of recursive calls to:
> >>
> >> cl_error
> >> cl_funcall
> >> L36error_type_specifier
> >> L3Universal_Error_Handler
> >> L30coerce_to_condition
> >> cl_typep
> >>
> >> The console logs show:
> >> Read or write operation to stream #<input stream "stdin">  
> signaled an
> >> error.
> >> Explanation: Resource temporarily unavailable.
> >> Broken at COMMON-LISP:ERROR.
> >>  
> QUAKE>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
> >>
> >>   
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
> >
> >>  >>>>>>>>>>>>>>>>>>
> >>
> >> My lisp and c code (cribbed from the xchat plugin and vbecl) are
> >> attached.
> >>  In the code I'm trying to use Cmd_Lisp_Eval with a lisp_code  
> string of "(+ 1 1)". The crash happens in cl_lisp.c at line 73  
> ("cl_object result = cl_safe_eval (form, Cnil, NULL);"). Does my  
> eval code look reasonable (like it's doing the right things)? As  
> quake is a GUI app without a useful stdin/out, what do I need to do  
> in ECL to prevent errors due to things trying to read *standard- 
> input* and friends? What am I missing in the way of housekeeping  
> (memory management, static roots for the GC, ...)? Thanks muchly,  
> -- Geoff Cant
> > --
> > David Creelman
> > GPG: 11CC 0D54 D37A 4B9C 5C65  AB63 5B18 7F99 7D77 9CA5
>

- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFD1ED0h5wddleX/1sRAqZ1AJ9SPwwX/NtsRWDs2nQav1M1z0SkPACeKsIl
36h8O2S5z3tE5OExz5Yftq0=
=NMDb
- -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFD1EECh5wddleX/1sRAsYuAJ4+P3PBpDG2c4zPkD5cSutjzCXHvgCcDvqT
Tfx8sNh5iXCFeyrSOPxa/6Q=
=mv3S
-----END PGP SIGNATURE-----




More information about the ecl-devel mailing list