Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ethan (3163)

  reversethis-{ed. ... rap.nov.olissat}

Being a 25-year old chap living in the western-most town of Germany. Stuying communication and information science and being a huge fan of XS-related things.

Journal of ethan (3163)

Tuesday June 22, 2004
04:13 AM

Working around bugs

[ #19419 ]

Doing that is something I absolutely hate, because it can make you look quite stupid. See this code:

sub validate {
    my $o = shift;
    while (@_) {
    my ($key, $val) = splice @_, 0, 2;
    if ($key eq 'UNDEF') {
        Inline::Lua->register_undef(\@$val), next if ref $val eq 'ARRAY';
        Inline::Lua->register_undef(\%$val), next if ref $val eq 'HASH';
        Inline::Lua->register_undef(\*$val), next if ref $val eq 'GLOB';
        Inline::Lua->register_undef(\&$val), next if ref $val eq 'CODE';

Now, why do I possibly dereference $val just to pass a reference to the dereferenced value? register_undef is an XSUB. What it receives when just passing the raw reference is for some reason an SvPVIV:

SV = PVIV(0x82a5ab8) at 0x81b9134
  REFCNT = 1
  IV = 0
  RV = 0x814a75c
  PV = 0x814a75c ""
  CUR = 0
  LEN = 0

Note that the ROK flag is still set.

It should be, of course, an SvRV. I am not yet sure who to blame. The above validate method is triggered by Inline so I suspect it might do funny things to its arguments. But this cannot be confirmed when looking at its code. Odd.

On a related note, Inline::Lua is done. 80% of the perldocs are there as well (and 0% of the tests, naturally). My ambitious plans layed out in my last journal entry all turned out to be feasible, even with less effort than I had expected. Perl and Lua can now happily exchange basic types, arrays, hashes, tables, filehandles and functions without getting confused. Tomorrow I'll possibly be able to release it to the CPAN.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.