[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: Newer xsubpp



On Sun, Jan 23, 2000 at 01:10:20AM -0800, Gurusamy Sarathy wrote:
> >The copy of xsubpp which I have on my disk allows for ANSI-style
                                              ^^^^^^
Note this: ---/

> >declarations, and in/inout/out modifiers.  Say, XSUB
> >
> >int
> >foo( in int a, out double b, inout IV c);
> >
> >can be used from Perl as
> >
> >($res, $b, $c_out) = foo($a, $c_in);
> >
> >Basically, 'in' is ignored, 'out' variables are not in the Perl
> 
> So why require them to specify 'in'?  Just make it the default.

It is allowed, not required.

> >parameter list, 'inout' variables are in the parameter list and in the
> >output list.
> >
> >Please tell me what you think.
> 
> Since this looks like just syntactic sugar over what XS already
> provides, it may be worth writing this as a preprocessor that emits
> the equivalent XS code.

The same could be said about conversion XS ==> C.  So the name of this
preprocessor is xsubpp.  ;-) But currently, xsubpp does not fulfill
its mandate in all but the most trivial cases.  To write any
not-absolutely-trivial XSUB one

  a) needs to know Perl internals in all the gory details;
  b) needs to write a bulky XSUB conversion code.

The purpose of xsubpp was to free the programmer from these mundane
parts of the programmer's job, and let him concentrate on the
description of the *interface* of the functions.  However, in typical
cases of 'out' and 'inout' arguments the current xsubpp API lacks a
lot.  My patch fixes this.

Another area of possible improvement is simplification of treatement
of C API which takes length of strings.  Say, currently one needs to
write something as horrible as

  double
  constant(sv,arg)
  PREINIT:
	  STRLEN		len;
  INPUT:
	  SV *		sv
	  char *	s = SvPV(sv, len);
	  int		arg
  CODE:
	  RETVAL = constant(s,len,arg);
  OUTPUT:
	  RETVAL

One could compact this as

  double
  constant(char *s, int length(s), SV *arg)

Ilya


Follow-Ups from:
Larry Wall <larry@wall.org>
References to:
Ilya Zakharevich <ilya@math.ohio-state.edu>
Gurusamy Sarathy <gsar@ActiveState.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]