in reply to Question about module interface style
Generally, it's a mistake to map a C interface directly to a Perl one. With some careful thought, you can usually do much better by moulding the interface to Perl's strengths. An example that springs to mind is the Win32 Registry API: painful and tedious to use from C, with all those API calls, and all that mucking about checking return codes. By contrast, Win32::TieRegistry is a joy to use: to read from the Registry, you just read from a (tied) hash; to write to the Registry, you simply write to the hash.
As described in On Interfaces and APIs, the way to go about designing a new API is to "play test" it. Write some tests for it. Start by imagining the perfect interface without worrying about implementation constraints. Then refine it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Question about module interface style (XS like C)
by tye (Sage) on Jul 23, 2006 at 17:05 UTC |