develooper Front page | perl.perl5.porters | Postings from November 2010

Re: [PATCH] Add "safe arrow/safe dereference" operator: &&->

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
November 14, 2010 11:46
Subject:
Re: [PATCH] Add "safe arrow/safe dereference" operator: &&->
Message ID:
20101114204627.786c5dcb@pc09.procura.nl
On Sun, 14 Nov 2010 10:50:47 -0600, Brad Gilbert <b2gills@gmail.com>
wrote:

> On Sat, Nov 13, 2010 at 8:46 PM, David Caldwell <david@porkrind.org> wrote:
> > On 11/13/10 11:51 AM +0000 Zefram wrote:
> >
> >> David Caldwell wrote:
> >>>
> >>>  This patch adds support for a new operator "&&->" that acts like arrow
> >>> but evaluates to undef if the left side is undef.
> >>
> >> Sounds potentially useful.  I find the spelling a bit unwieldy, and in
> >> particular the two-token treatment makes recursive-descent handling of
> >> it tricky.  I suggest the spelling "&->", as a single token.
> >
> > That would be easy enough to change, I think. At one point I had "&&->"
> > being tokenized as a whole but I opted for the 2 token approach since it was
> > a more minimal patch. Andrew Rodland suggested "|->", but I think "&->" is
> > more intuitive as to what it actually does. I'm still kind of partial to
> > "?->" if I can figure out how to make it work.
> >
> >   $something&&->here
> >   $something&->here
> >   $something|->here
> >   $something?->here
> >
> > The main question is, would this change anyone's mind who thinks this is
> > currently not a patch worth applying?
> >
> > -David
> >
> > Extra random brainstorms:
> >   $something?>here
> >   $something&>here
> >   $something-=>here

^ I like that one 

Personally I think &&- adds too much noise. Though very useful, I
probably won't use it, because it is so ugly. My opinion is of course
my opinion, and not a rule of thumb.

> >   $something*->here
> >   $something:->here
> >   $something??->here
> >
> 
> I would like to point out that there are many 2 character options available,
> that are currently compilation errors:
> 
> $something~>here
> $something!>here
> $something%>here
> $something^>here

^ useful too.

> $something&>here
> $something*>here
> $something:>here
> $something+>here
> $something?>here
> 
> It's also possible to use the following (but probably not worth it for
> other reasons):
> 
> $something.>here
> $something,>here
> $something/>here

but //> would have a nudge towards // which is the behaviour we're
looking at

> $something|>here
> 
> $something}>here
> $something]>here
> 
> $something-]here
> $something-}here

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

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