develooper Front page | perl.perl5.porters | Postings from February 2012

Re: proposal on defined and exists

Thread Previous | Thread Next
From:
Reini Urban
Date:
February 22, 2012 23:15
Subject:
Re: proposal on defined and exists
Message ID:
CAHiT=DHi28L8wnfEf1qtnTPT6GGr9e7rpv1Gd7LceEJWmMZ44g@mail.gmail.com
On Sat, Feb 18, 2012 at 4:11 AM, Nicholas Clark <nick@ccl4.org> wrote:
> On Fri, Feb 17, 2012 at 10:18:57PM -0600, Reini Urban wrote:
>
>> I proposed exists to clarify the meaning against the abuse of
>> defined() to test for defined'ness and to help the language.
>
> Perl, abusing defined since 1989:
>
> $ ./perl -e 'sub def {print defined $a ? "Yes\n" : "No\n";}' -e '&def(); $a = "$]\n"; &def();'
> No
> Yes

Nonsense. defined for a global SCALAR never was in discussion. In
discussion was the meaning for defined with ARRAY, HASH and esp. CODE.

People use defined ARRAY for the existence of the array, not if it's empty.
defined(&code) is widely used because it just happens to work.
And for consistency I added lexicals to the mix.
-- 
Reini

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About