I'm looking for a way to have an EVAL like wrapper around a piece of code in my XS module (XML::Parser::Expat.) I know about the G_EVAL flag to use with perl_call_sv, but it looks like it probably adds significantly more overhead to perl_call_sv calls, right where XML::Parser can least afford it. And I don't think I need to catch exceptions after each handler. If a parse fails, the low level parser object should be reclaimed anyway. Currently exceptions are caught in the XML::Parser parse method with an eval wrapped around a call to the XML::Parser::Expat parse method. There's a problem, though, if an exception occurs while parsing an external entity. Expat requires you to create a subsidiary parser for external entities and recursively parse them. This parser should be reclaimed after you're through with the external entity. Currently this won't happen when an exception occurs in the subsidiary parse. Also I've realized that I need to provide a pair of callbacks for external entities to the user in order for them to cleanly use an IO::Handle to read from an external entity. One to open the Handle and one to close it. (Also useful for pushing and popping the current basename.) If an exception happens during the parse, you still want the corresponding finishing callback to made. I was considering experimenting with cutting and pasting the "if (G_EVAL & flag) {...}" blocks from perl_call_sv and adapting them to the externalEntity handler in Expat.xs, but this seems exceedingly fragile. I was also thinking about using perl_call_sv on a sub that just calls an XS function that wraps the code in question. The only purpose of the sub is for me to use perl_call_sv with G_EVAL. This is what I'll probably do unless I'm advised otherwise by you folks. If you have advice for me, please CC: it to me as well as the list. Thanks, Clark -- Clark Cooper Software Engineer Home: coopercc@netheaven.com Schenectady, NY USA Work: cccooper@ltionline.comThread Next