The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tie::Array::Lazier - Lazier than Tie::Array::Lazy

VERSION

$Id: Lazier.pm,v 0.2 2012/08/09 19:07:27 dankogai Exp $

SYNOPSIS

  use Tie::Array::Laier;
  # 0..Inf
  tie my @a, 'Tie::Array::Laier', [], sub{ $_[1] };
  $a[3] = 'three'; # $self->array is [undef, undef, undef, 'three']
  print "$_\n" for @a; # 0, 1, 2, 'three', 4 ...

DESCRIPTION

Tie::Array::Lazier is a child class of Tie::Array::Lazy that behaves a lot like its parent except for one thing; It is even lazier.

Instead of filling elements up to $index, Tie::Array::Lazier It calls $self->maker when $self->array->[$index] is undef. Therefore you cannot store undef to the tied array.

EXPORT

None.

FUNCTIONS

Same as Tie::Array::Lazy.

note on $_[0]->index vs $_[1]

While $_[0]->index is identical to $_[1] in Tie::Array::Lazy>, these values may disagree in Tie::Array::Lazier Whenever you need the index, use $_[1].

  # 0..Inf
  tie my @a, 'Tie::Array::Lazier', [], sub{ $_[0]->index }; # wrong!
  tie my @a, 'Tie::Array::Lazier', [], sub{ $_[1] };        # right!

You can still use $_[0]->index to find how many elements the internal array holds.

AUTHOR

Dan Kogai, <dankogai at dan.co.jp>

BUGS

See Tie::Array::Lazy.

SUPPORT

See Tie::Array::Lazy.

ACKNOWLEDGEMENTS

See Tie::Array::Lazy.

COPYRIGHT & LICENSE

Copyright 2007 Dan Kogai, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.