From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani
Here's a broad outline of what I have in mind.Thanks, that looks really good. Just a few minor issu= es that I encountered over the last couple of weeks.=C2=A0=Thread-local environments
-------------------------
The `get_environment' member lets us do anything else interesting. As in Java, environments are thread-local. We only support one thread for
the moment, so this constraint is easy to enforce. (Just abort if we
use an emacs_env off the main thread.)= Would you really abort, or rather use the error handling functions? We shou= ld be able to make the error values thread-local so that calling a function= from the wrong thread would be the equivalent of raising a signal, giving = the caller a chance to react. Otherwise the burden of remembering the corre= ct thread would be on the caller's side.=C2=A0=C2=A0 typedef struct emacs_value_tag* emacs_value;<= br>
=C2=A0 typedef emacs_value (*emacs_subr)(
=C2=A0 =C2=A0 emacs_env* env,
=C2=A0 =C2=A0 int nargs,
=C2=A0 =C2=A0 emacs_value args[]);
=C2=A0 =C2=A0emacs_va= lue (*make_function)(
=C2=A0 =C2=A0 =C2=A0 emacs_env* env,
=C2=A0 =C2=A0 =C2=A0 int min_arity,
=C2=A0 =C2=A0 =C2=A0 int max_arity,
=C2=A0 =C2=A0 =C2=A0 emacs_subr function);
=C2=A0 =C2=A0 emacs_value (*funcall)(
=C2=A0 =C2=A0 =C2=A0 emacs_env* env,
=C2=A0 =C2=A0 =C2=A0 emacs_value function,
=C2=A0 =C2=A0 =C2=A0 int nargs,
=C2=A0 =C2=A0 =C2=A0 emacs_value args[]);
= Modules can use make_global_reference to allocate a global reference
(i.e., a GC root) for any emacs_value; modules must then free these
references explicitly.
All routines (except make_global_reference) that return emacs_value
values return local references.=C2=A0 It's up to modules to register
long-lived references explicitly.
If Lisp signals or throws, `funcall' returns NULL.<= br>
1) Do we need JNI-style local variable frames and functions that<= br> =C2=A0 =C2=A0release local references?
2) Maybe we want a separate, non-emacs_value type for global references?
3) How exactly do we represent catch/throw values?