XS Constants peculiarity
Dave Mitchell
davem at iabyn.com
Thu Oct 28 13:39:36 BST 2010
On Thu, Oct 28, 2010 at 11:03:14AM +0100, Dirk Koopman wrote:
> A few years ago I put together an XS interface to an internal
> program writing system that a company I work for occasionally uses.
>
> The constants are standard ones that XS generates (i.e. integers) and
>
> perl -e 'use FF; printf "0x%x\n", $_ for (LOCK, RK, RK | LOCK, RK
> + LOCK)'
>
> yields:
>
> 0x100000
> 0x4
> 0x100004
> 0x4
>
> Why would RK + LOCK give a different result to RK | LOCK?
Your module is probably creating and exporting constant subs without the
() prototype, in which case A + B is parsed as A(+B):
$ cat /tmp/p
#!/usr/bin/perl
use feature 'say';
sub A1 { 1 }
sub A2 { 2 }
sub B1() { 1 }
sub B2() { 2 }
say A1 + A2;
say B1 + B2;
$ perl /tmp/p
1
3
--
Never do today what you can put off till tomorrow.
More information about the london.pm
mailing list