Why array variable names have magic? What is this for?

65 views Asked by At

Fetching the name of variable from PAD_COMPNAME shows that the name is magical:

SV *sv =  PadnameSV( PAD_COMPNAME( cPADOP->targ +ix ) );
do_sv_dump( 0, Perl_debug_log, sv, 0, 10, 0, 0 );

SV = PV(0x1c1ed40) at 0x1c1bb30
  REFCNT = 1
  FLAGS = (POK,pPOK,UTF8)
  PV = 0x19eb480 "@y"\0 [UTF8 "@y"]
  CUR = 2
  LEN = 10
  MAGIC = 0x1a58340
    MG_VIRTUAL = &PL_vtbl_arylen_p
    MG_TYPE = PERL_MAGIC_arylen_p(@)
    MG_FLAGS = 0x02
      REFCOUNTED
    MG_LEN = 8
    MG_PTR = 0x19eb460 "\0\0\0\0\0\0\0\0"
  ARRAY = 0x0
  FILL = -1
  MAX = -1
  ARYLEN = 0x0
  FLAGS = (REAL)

Why we need magic for variable name? What is this for?

0

There are 0 answers