Jim Bodwin wrote:
You are not overloading the object, you are overloading the reference.

Um, that's how overloading works:

$ perl -Mversion -MDevel::Peek -e '$vobj = qv("1.2.3");
print Dump($vobj);'
SV = RV(0x81c9750) at 0x8170cdc
  REFCNT = 1
  FLAGS = (ROK,OVERLOAD)
  RV = 0x8171798
  SV = PVHV(0x8175790) at 0x8171798
    REFCNT = 1
    FLAGS = (OBJECT,SHAREKEYS)
    IV = 2
    NV = 0
    STASH = 0x81718e8   "version"
    ARRAY = 0x8190c80  (1:2)
    hash quality = 125.0%
    KEYS = 2
    FILL = 2
    MAX = 1
    RITER = 0
    EITER = 0x0
    Elt "qv" HASH = 0x18c4b28a
    SV = IV(0x818f36c) at 0x8170cf4
      REFCNT = 1
      FLAGS = (IOK,pIOK)
      IV = 1
    Elt "version" HASH = 0x68c27e33
    SV = RV(0x81c974c) at 0x81f4d3c
      REFCNT = 1
      FLAGS = (ROK)
      RV = 0x8170d90
      SV = PVAV(0x8175c64) at 0x8170d90
        REFCNT = 1
        FLAGS = ()
        IV = 0
        NV = 0
        ARRAY = 0x81a2c70
        FILL = 2
        MAX = 3
        ARYLEN = 0x0
        FLAGS = (REAL)
        Elt No. 0
        SV = IV(0x818f370) at 0x817181c
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 1
        Elt No. 1
        SV = IV(0x818f374) at 0x81717ec
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 2
        Elt No. 2
        SV = IV(0x818f378) at 0x81f4c7c
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 3

Objects, themselves, cannot have overloading magic associated with them, only references have that ability.

Now, it is possible to have references to objects inside of a composite object that are themselves overloaded, but that's probably not nearly as common a usage of overloading as the top-level reference.

John

--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748

Reply via email to