On 1 December 2010 16:07, Ed Avis <eda@waniasset.com> wrote:
> David Golden <xdaveg <at> gmail.com> writes:
>
>>It was described more or less as "if defined, continue, otherwise
>>return undef".
>
> How about 'if exists, continue, otherwise return undef'?
>
> my %h;
> $h{foo} = undef;
> $h{bar}->>x(); # no-op
> $h{foo}->>x(); # dies?
>
> To my mind, an explicit undef in there indicates something that should barf when
> you try to dereference it, and is different from a missing hash key or array
> entry.
>
> When the LHS is not an array or hash lookup then the test must be definedness
> not existence. But if it is, we have a choice of semantics.
I have to admit i worry a bit that introducing syntax that makes "key
associated to undef" and "undef by virtue of key not existing"
different things is likely to be a real source of confusion.
OTOH, im not totally against the idea.
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
Thread Previous
|
Thread Next