Embed questions

kjstol parrotcode at gmail.com
Mon Oct 25 17:58:57 UTC 2010


Perhaphs have a look at quite a successful other language/interpreter:  Lua.
I dont' know details, but Lua is quite successful as a tiny language
that can be embedded.

hth,
kjs

On Mon, Oct 25, 2010 at 2:25 AM, Andrew Whitworth <wknight8111 at gmail.com> wrote:
> Some people may have seen some recent traffic on my blog [1][2]. A
> Parrot user is trying to do some stuff with embedding a Parrot
> interpreter into a 3D game engine, and is having a hell of a lot of
> trouble doing it. I would like to rectify these problems before the
> next release, but I have two questions that I would either like
> answers to, or would like to generate enough discussion that I can
> confidently come up with my own [experimental] solutions. So, here
> they are:
>
> 1) The most specific question that was generated on my blog is this:
> How does an embedding application load a bytecode file into a Parrot
> interpreter? There is function Parrot_load_bytecode, but that function
> throws an exception on error and does not return a value. Is it
> worthwhile to create a new API function for external uses that is
> easier to use in cases where we have a PBC file and we just want to
> load it without having to go through the hassle of registering a
> C-level exception handler? Also, it looks like this function is only
> ever really used from the load_bytecode opcode, there are no examples
> of it being used elsewhere.
>
> For comparison, IMCC goes through this kind of dance when a .pbc file
> is specified from the commandline:
>
> Packfile * pf = Parrot_pbc_read(interp, ...);
> Parrot_pbc_load(interp, pf);
>
> It looks to me like neither of these functions throw exceptions, and
> both of which are available in embed.c, but are these the functions we
> want to use for this purpose or can we come up with a better API?
>
> 2) How to we propagate unhandled errors and exceptions? That is, how
> do we communicate an error condition to an embedding application?
> Parrot *can not* just write error messages and unhandled exception
> messages to STDERR. We do need a way to allow an embedding application
> to detect an error and receive information about it. An example that
> comes to mind immediately is the Win32 API, where most API functions
> return a 0 on error, and the function GetLastError returns information
> about it. I don't think we want to copy this model, but embedding
> applications do need a way to redirect where error information goes,
> including not writing it to any file. Simply overriding the PMC used
> for the interpreter's STDERR handle doesn't work in all cases. Look in
> the code for Parrot_io_eprintf for examples. To a search through the
> codebase for "fprintf" and "stderr" for others.
>
> We absolutely need a standard method for embedding applications to
> detect fatal and otherwise unhandled errors generated by an
> interpreter, and we need a method for the embedding application to get
> information about that error and present it to the user in a
> completely customizable way.
>
> Thanks,
>
> --Andrew Whitworth
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>


More information about the parrot-dev mailing list