This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: Representation of VM programs---applicable smobs?
Keisuke Nishida <kxn30@po.cwru.edu> writes:
> How will the API look like?
> I would like the following:
>
> static long scm_program_tag;
>
> SCM
> scm_apply_program (SCM program, SCM args)
> {
> return scm_vm_apply (some_vm, program, args);
> }
>
> static void
> scm_init_program ()
> {
> scm_program_tag = scm_make_smob_type ("program", 0);
> scm_set_smob_apply (scm_program_tag, scm_apply_program);
> }
In order to make things easy, efficient (no unnecessary consing) and
consistent (with the gh_new_procedure and SCM_DEFINE interfaces) I was
thinking more like:
scm_set_smob_apply (scm_program_tag, scm_apply_program, 0, 0, 1);
> Implementing this will be fairly easy. Could you do this soon?
> Or could I help?
If you know how to do it please just go ahead.
We should add two new fields to scm_smob_descriptor: `apply' and
`gsubr_type' (which will contain the result returned by
SCM_GSUBR_MAKTYPE).
The scm_tc7_smob cases in the evaluator should check the `apply'
field. If that field contains NULL, the smob application will result
in the same error as now, that is "wrong type to apply". If it is
non-NULL, scm_smob_apply_0 (smob), scm_smob_apply_1 (smob, a1),
scm_smob_apply_2 (smob, a1, a2) etc will be called (one function for
each major switch in the evaluator).
Each scm_smob_apply_X (which should reside in smob.c) contains a
switch which dispatches on the smob application type in order to
select the correct form of call.
Don't forget the debugging evaluator! (You can look at how one of the
subrs are handled.)