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

Re: New way to do XS constants



On Fri, Jan 07, 2000 at 09:58:56AM +0000, Tim Bunce wrote:
> FYI: All those advantages also apply to this very simple method:
> 
>   I32
>   constant()
>         PROTOTYPE:
>     ALIAS:
>         CONST_NAME_1 = 1
>         CONST_NAME_2 = 2
>         CONST_NAME_3 = 3
>         CONST_NAME_4 = 4
>     CODE:
>     RETVAL = ix;
>     OUTPUT:
>     RETVAL
> 
> (The 1, 2, 3, 4 can be #defined values.)
> 
> Using a single XS sub and multiple XS aliases instead of multiple perl
> subs uses very little memory (far less than multiple perl subs).
> It also has a very low start-up overhead (just one newXS() call each).

But this does not create a constant sub. It also does not allow you use
#ifdef for the constants.

Take a look at the end of IO.xs

Graham.


Follow-Ups from:
Tim Bunce <Tim.Bunce@ig.co.uk>
References to:
Tye McQueen <tye@metronet.com>
Tim Bunce <Tim.Bunce@ig.co.uk>

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