I've generally been fairly quiet on this thread, mostly thanks to
an...ambitious work travel schedule, though I've been trying to
keep an eye on the discussion.
I'm pleased that I don't see a whole lot of opposition to the concept of
defined-dereference, just a whole lot of discussion around the right
syntax for the feature.
Initially, I was fairly opposed to &&-> for the same reason I don't
like ~> -- It makes it quite hard to read a chunk of code:
if ($foo&&->{bar}&&->baz(23)&&->{biff} && $thing->true)
All I saw was a sea of ampersands.
I've popped up on #p5p a few times to talk about the then-current state
of syntax proposals. One of my favorites was -&>
if ($foo-&>{bar}-&>baz(23)-&>{biff} && $thing->true)
While Perl 5 and Perl 6 have diverged somewhat in terms of method call
syntax, I decided that this might be a good time to use a
phone-a-friend.
Larry explained to me that Perl 6's .? is probably the closest relation
to the feature we're now mooting. P6 has other methods for "call all
of" -- also inspired by regexy syntax.
if ($foo->?{bar}->?baz(23)->?{biff} && $thing->true)
The recommended "->?" wasn't initially my top choice for the feature
in question, but between "match 0 or 1 times, like a regex" and that it
looks a bit like half of a ternary operator[1], it's definitely _become_
my top choice.
I'd like to focus this discussion somewhat narrowly for a bit:
Why _shouldn't_ we bless ->? as the correct syntax for "defined/safe
dereference"?
Best,
- Jesse
[1] And yes, only the left half of a ternary operator. If anyone wants
to know where the colon went, well, Larry got it.
Thread Previous
|
Thread Next