in reply to Re^3: Booleans from flip-flops
in thread Booleans from flip-flops

Fascinating, I never heard about dualvars nor that scalars have slots...

Seems only to be explained in Scalar::Util

Cheers Rolf

Replies are listed 'Best First'.
Re^5: Booleans from flip-flops
by ikegami (Patriarch) on Jan 20, 2010 at 19:19 UTC
    IV - holds signed int, unsigned int or ref NV - holds float PV - holds string

    And then there are fields to support magic lvalues and general magic.

    Not every field is available at all times. SVs (scalars) have a head which contains a pointer to the body. The body is automatically upgraded when needed (e.g. my $x = 1; $x += 0.1;, tie my $x, ..., etc).

    And even if the field is available, not all values are available at all times. Flags indicate which fields are initialised and what they contain.

    $ perl -MDevel::Peek -e' my $x; Dump $x; $x = 123; Dump $x; "$x"; Dump $x; ++$x; Dump $x; $x=undef; Dump $x; ' Fresh var, no body, no content: SV = NULL(0x0) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY) After assigning int, body upgraded to IV (has field IV), and IV field contains a number (IOK): SV = IV(0x88c691c) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 123 After using content as string, body upgraded to PVIV (has fields IV and PV), IV field contains a number (IOK), and PV field contains a string (POK): SV = PVIV(0x88c56ac) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY,IOK,POK,pIOK,pPOK) IV = 123 PV = 0x88e7710 "123"\0 CUR = 3 LEN = 4 After using content as a number, IV field contains a number (IOK), and PV field isn't being used (!POK): SV = PVIV(0x88c56ac) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 124 PV = 0x88e7710 "123"\0 CUR = 3 LEN = 4 After clearing the contents, IV field isn't being used (!IOK), and PV field isn't being used (!POK): SV = PVIV(0x88c56ac) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY) IV = 124 PV = 0x88e7710 "123"\0 CUR = 3 LEN = 4
      Thanks, this reminded of the panther book (1st print). Thankfully I found an old copy in a local library.

      It's the best compilation of perl internas I found till today...always wanted to work through it in detail!

      ... a pity it's not continued anymore! 8(

      Any other recommendations for perl opcodes and internal data formats?

      Cheers Rolf