>>>>> "LP" == Luke Palmer <[EMAIL PROTECTED]> writes:

  LP> Actually, you can think of undef pretty much as defining
  LP> autovivification.  "If you use it as a number, it becomes a number; if
  LP> you use it as a string, it becomes a string; if you use it as a hash,
  LP> it becomes a hash; ..."

  LP> However, that's not really accurate, because:

  LP>     # perl 5
  LP>     my $x;
  LP>     $x->{4} = 1;
  LP>     print $x;   # "HASH(...)"

  LP>     my $x;
  LP>     my $y = $x + 1;
  LP>     print $x;   # not "0"

those aren't the same either. in p5 only undef when used as a ref gets
autovivified to the appopriate anon ref. undef when used as a regular
scalar value stays undef. the deref thing was created to handle
assigning to multilevel structures without needing to explicitly set
each of the upper levels (think about how much extra code this one
little feature has saved us all!). since in p5 undef coerces to 0 or ''
as needed (wherever the undef came from), it doesn't change the value of
the undef.

and i agree with luke that the idea is interesting but it should be a
stricture. it is not a good idea for default as it ruins
autovivification. also it would ruin many one liners and short scripts
which don't even use regular strict. perl's ability to dwim undef and
not carp or croak is a good default. just use pragmas to make it
stricter in larger programs.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to