On Fri, Jan 31, 2003 at 05:59:46PM +0100, Leopold Toetsch wrote:
> A lvalue param is not strictly reading, but here has to happen something 
> differently - yes:
> 
> IMHO some sort of proxy could be passed here, saying: "if you write to 
> me, this will be at @a[0]". Or auto-vivify the entry.

This is what Perl 5 does at the moment:

$ perl5.8.0 -MDevel::Peek -e 'sub f{Dump($_[0])}; f($a[9])'
SV = PVLV(0x8177118) at 0x8166a74
  REFCNT = 1
  FLAGS = (GMG,SMG)
  IV = 0
  NV = 0
  PV = 0
  MAGIC = 0x816e7e0
    MG_VIRTUAL = &PL_vtbl_defelem
    MG_TYPE = PERL_MAGIC_defelem(y)
  TYPE = y
  TARGOFF = 9
  TARGLEN = 1
  TARG = 0x817ad88
SV = PVAV(0x8183bd4) at 0x817ad88
  REFCNT = 2
  FLAGS = ()
  IV = 0
  NV = 0
  ARRAY = 0x0
  FILL = -1
  MAX = -1
  ARYLEN = 0x0
  FLAGS = (REAL)

However, I think this is clumsy and overly complex; since Perl6 allows us
to declare parameters rw or whatever, I think it should always autovivify
unless we know the param is read-only (or in-only, or whatever the correct
terminology is).

-- 
"There's something wrong with our bloody ships today, Chatfield."
Admiral Beatty at the Battle of Jutland, 31st May 1916.

Reply via email to