[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compund units in extensions



Quoting Robert John Andersen:
> > > and the exports
> > > argument ((A (a1 a2) (B b1)).
> 
> So it would be ((A a1 a2)(B b1))

Right, at least according to the docs. But after inspecting the code
for scheme_assemble_compound_unit(), I see that the documentation is
wrong. (Thanks for the example code!)

For `exports', scheme_assemble_compound_unit() actually expects a list
where every individual exported variable is represented by a separate
item. More specifically, the exports argument should be

 A list of export specifications, where each export specification is a
 pair consisting of
  * a tag symbol
  * a symbol naming one export from the corresponding sub-unit
    (used as both the name of the sub-unit export and the name
    of the compound unit's export), or a pair of symbols where the
    first one is the name of the sub-unit's export and the second
    one is the name as exported from the compound unit

To make try-ext.c work, change exports_unit1() to

 Scheme_Object *exports_unit1() {
   return scheme_make_pair(scheme_intern_symbol( "unit1" ),
                           scheme_intern_symbol( "one" ));

 }

Matthew