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

Re: proposal on defined and exists

Thread Previous | Thread Next
From:
Michael Peters
Date:
February 16, 2012 14:18
Subject:
Re: proposal on defined and exists
Message ID:
4F3D8062.7070409@plusthree.com
On 02/16/2012 04:04 PM, Zefram wrote:

>> non-vivify           vififies *symbol
>> exists(*symbol)<==>  defined *{symbol}{GLOB}   // currently nonsense
>> exists($scalar)<==>  defined *{symbol}{SCALAR} // currently nonsense
>> exists(@array)<==>  defined *{symbol}{ARRAY}
>> exists(%hash)<==>  defined *{symbol}{HASH}
>> exists(&sub)<==>  defined *{symbol}{CODE}
>
> There's a problem with the concept here.  A mention of "@foo" (or with
> any of the other sigils) brings the glob into existence at compile time.
> By the time the "exists" operation runs, it's too late to avoid vivifying
> it.  Now, we *could* special-case it, but I'd rather not.

What about forcing it to be run-time by using strings?

exists('*symbol');
exists('$scalar');
exists('@array');
exists('%hash');
exists('&sub');

-- 
Michael Peters
Plus Three, LP


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