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

[MacPerl-Toolbox] Re: [MacPerl] IN, OUT, INOUT parameters



Quoting Matthias Neeracher <neeri@iis.ee.ethz.ch>:

> My philosophy for Toolbox API ports so far has been to have *NO* out
> parameters. No exceptions. I believe that out parameters fit badly into
> the perl design.
> 
For Brian's edification, I think it's worth adding that for functions
of the form

resultCode = func(in, out)

which is essentially what WENew is like, where the "out" is a pointer, the
obvious Perl equivalent is

$out = func($in);

where the "resultCode" gets subsumed into the output, by setting $out to
zero on error. A pointer won't be zero and hence signals error. This
assumes that the particular type of error is of no consequence. But if
that is really needed too, then we can set a global error variable.

Getting the XSUB to work this way is a matter of a few lines of XS code,
or using a "helper function" in your SWIG interface (for a SWIG wrapper
function).

While we're at it, I happen to be using Scrap.h as an example for my SWIG
tutorial, because it's small, it illustrates some interesting points, and
because it appears not to have been XS'ed. Concerning the latter, did I
miss something? I don't know how useful the Scrap calls are in the big
scheme of things, but they must have some utility, surely? :-) Just curious.

Arved


---------------------------------------------------------------
 This mail was sent through the Nova Scotia Provincial Server.
 http://nsaccess.ns.ca/mail/ (in development)

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org