I still think it'd be neat to have a special Undef class of some sort
which can be subclassed and further defined to really DWIM rather than
be stuck with whatever pragmas Perl has graciously built in. Something
like this would require more thinking and speculation -- and it may
hurt performance too much to be practical, though.

Obviously there are mixed opinions of how undef should be treated and
some won't be happy with what becomes final, so implementing some
intelligent defaults and simple pragmas, but not excluding the ability
to *really* control your undefs, sounds like a win-win.

- sebastian

On 12/17/05, Uri Guttman <[EMAIL PROTECTED]> wrote:
> >>>>> "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