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

Re: Exceptional question



Quoting Bertrand Petit:
> 	It seems from the schexn.h header that exception that could be
> raised from extension libraries are fixed at interpreter
> compile-time. Is there other ways to define new expections (and raise
> them) from C extension libraries?

It's true that scheme_raise_exn() works only with a fixed set of
exceptions. But you can use the more general `raise' that takes an
arbitrary value (usually an instance of a struct type derived from
`struct:exn').

The C form of `raise', a scheme_raise() function, exists within
MzScheme but wasn't made accessible to extensions in 103.X. (Actually,
if you're in Linux, Solaris, or FreeBSD, scheme_raise() is accessible
butq not prototyped.) In 199.X the scheme_raise() function is exported
to extensions.

Meanwhile, you can lookup the global binding of `#%raise' and call it
with scheme_apply().

To define a new exception type, lookup the global binding of
`#%struct:exn' and use scheme_make_struct_type(), etc.

Matthew