develooper Front page | perl.perl5.porters | Postings from October 2003

Re: RFC: changing behavior of defined() and exists()

Thread Previous | Thread Next
Rafael Garcia-Suarez
October 9, 2003 15:20
Re: RFC: changing behavior of defined() and exists()
Message ID:
Abigail wrote:
> Having said that, I don't think the added convenience for just exists
> outweigths the drawback of added complexity to the language. Perhaps
> if Perl had next to truth/defined/exists a handful of similar notions
> that could have been dealt with in one consistent fashion that this
> patch would be useful. 
> Having said that, I must say that I find that Roy's proposal has some
> interesting ideas.

I found Roy's original proposal in c.l.p.misc more interesting that his
second (extended) one : basically, this was to allow the return value
of defined() and exists() to be used in a lvalue context with ||= and &&=.

Id est :
	defined($foo) ||= 'default';
	$foo //= 'default';
	exists($hash{key}) &&= 'replacement';
	if (exists($hash{key})) { $hash{key} = 'replacement' }

If we keep only this idea, this is only an extension to existing
syntax, backwards-compatible.

The only sane way to implement this is probably with a bunch
of optree rewriting at optimization time. This means that it's
probably possible to implement it with Arthur's
And to put it on CPAN and to avoid bloating the core and to
port it to older perls ! yoohoo ! (any takers?)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About