Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^7: XS: returning a 64-bit unsigned int?

by ikegami (Pope)
on Sep 27, 2011 at 18:00 UTC ( #928130=note: print w/ replies, xml ) Need Help??


in reply to Re^6: XS: returning a 64-bit unsigned int?
in thread XS: returning a 64-bit unsigned int?

If they're redundant, don't do them. Generally speaking, though, they're not redundant. The outcome of each test is independent of the others. Magic can be tied to an element without being tied to the array, and the use of GET and SET magic is independent.

$ perl -MDevel::Peek -E' sub TIESCALAR { bless \my $x; } sub FETCH { 3 } my @a = (6,7); tie $a[1], __PACKAGE__; say $a[0]; say $a[1]; Dump(\@a); ' 6 3 SV = IV(0x9a22324) at 0x9a22328 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x9a3c2e8 SV = PVAV(0x9a23174) at 0x9a3c2e8 REFCNT = 2 FLAGS = (PADMY) ARRAY = 0x9a3af28 FILL = 1 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = IV(0x9a21764) at 0x9a21768 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 6 Elt No. 1 SV = PVMG(0x9a64d50) at 0x9a21898 REFCNT = 1 FLAGS = (GMG,SMG,RMG,pIOK,pPOK) IV = 3 NV = 0 PV = 0x9a370d0 "3"\0 CUR = 1 LEN = 12 MAGIC = 0x9a46460 MG_VIRTUAL = &PL_vtbl_packelem MG_TYPE = PERL_MAGIC_tiedscalar(q) MG_FLAGS = 0x02 REFCOUNTED MG_OBJ = 0x9a22258 SV = IV(0x9a22254) at 0x9a22258 REFCNT = 1 FLAGS = (ROK) RV = 0x9a4f4a0


Comment on Re^7: XS: returning a 64-bit unsigned int?
Download Code
Re^8: XS: returning a 64-bit unsigned int?
by BrowserUk (Pope) on Sep 27, 2011 at 18:09 UTC
    Magic can be tied to an element without being tied to the array.

    I know. That's why it is so expensive to cater for.

    The fact that almost no one uses tied scalars for anything makes it all the worse.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Tie is only one kind of magic. Magic scalars are actually quite common.

      $1 $| $ENV{PATH} $ISA[0] $tied{$k} $tied[$i] $#a pos substr

      (Some of these only return magical scalars in lvalue context.)

      Every tied hash and array uses them in order to call STORE on the hash or array when assigning to the scalar returned by $tied{$i} and $tied[$i].

        And how many of those am I going to find inside an array?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928130]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-09-16 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (53 votes), past polls