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

Re: Trying to create a struct in a Mzscheme extension.



Quoting PJ Durai:
> Is there something more I need to do in the above code?. (Something like
> "Need to add this typename to the Global environment" etc.) 

Yes, you need to add the values returned by scheme_make_struct_values()
to the top-level environment.

The scheme_make_struct_values() function doesn't affect the
environment; it only creates the struct procedures. The `names'
argument to scheme_make_struct_values() is used to set the internal
names of the procedures (for error reporting).

So you want something like

 Scheme_Object **vals;
 ...
 vals = scheme_make_struct_values(new_type, struct_names, count_out, 0); 
 for (i = 0; i < count_out; i++)
   scheme_add_global_symbol(struct_names[i], vals[i], env);

Matthew