in reply to Re: Question about module interface style
in thread Question about module interface style
Note that I wrote Win32::TieRegistry and I find that the things I most hate about many XS modules are caused by their attempts to provide a Perl-like interface. If you look under the covers of Win32::TieRegistry you'll find Win32API::Registry which provides a very raw transation of the C API for dealing with the Win32 Registry. There are a few minor niceties added to Win32API::Registry's API, but only ones that I was sure didn't take away any of the possible ways to use the C API and that couldn't be more easily implemented in Perl (actually, some of the niceties are implemented in Perl wrappers inside Win32API::Registry).
Trying to make Perl-like interfaces in XS is usually a grave mistake, IMO. Even fairly minor steps in that direction tend to lead to code that is hard to write, hard to debug, hard to extend, breaks easily in the face of the simplest of things (a Perl upgrade or any type of Perl magic such as tie), is more likely to have ref-counting bugs, etc.
Make XS interfaces that are very C-like and expose the full power of the underlying API and then provide Perl wrappers that provide a Perl-like interface. Take Tuppence's advice.
- tye
|
|---|