
h.m.brand at xs4all
Jun 1, 2012, 1:08 AM
Post #80 of 80
(57 views)
Permalink
|
|
Re: the old new safe dereference operator
[In reply to]
|
|
On Thu, 31 May 2012 16:26:22 +0100, Nicholas Clark <nick [at] ccl4> wrote: For those not following the discussion on PerlMonks, *this* reply from Tye is worth reading: http://www.perlmonks.org/?node_id=973680 > So, current "issues" are threefold? > > On Wed, May 30, 2012 at 12:05:16PM +0200, Philippe Bruhat (BooK) wrote: > > On Thu, May 24, 2012 at 09:51:16PM -0400, Ricardo Signes wrote: > > > > > > Hey, who else remembers $xyz->{foo}?->{bar}? > > 0: What's actually the best spelling? For type-ability, readability, and > guess-ability. > > 1: This one: > > > What about implicit dereference? > > > > I think the option that makes more sense is for implicit dereference to > > be performed using the last explicit dereference operator. > > > > So, > > > > $xyz?->{foo}{bar} # both safe > > > > $xyz->{foo}{bar} # both regular > > > > This makes it easy to switch in the middle of an expression, > > while not annoyingly verbose: > > > > $xyz->{foo}?->{bar}{baz} # regular, and then all safe > > > > The dereference operator needs to explicit around method and > > subroutine calls, anyway. > > 2: What does it mean in the context of an LVALUE construction? > > eg what does this do: > > ++$a?->b(); > > > a) skip the entire statement if $a is undef > > b) generate a runtime error if $a is undef, much like this does: > > $ perl -wle '${\undef}++' > Modification of a read-only value attempted at -e line 1. > > c) fail at compile time (for now) - simply restrict the use safe > dereference within LVALUE expressions, as it's a trap. > > d) something else > > > and I agree with Ricardo - the best way to resolve this seem to be a patch > on a branch. > > Nicholas Clark -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.14 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
|