develooper Front page | perl.perl5.porters | Postings from August 2013

Re: postfix dereference syntax

Thread Previous | Thread Next
Johan Vromans
August 15, 2013 07:44
Re: postfix dereference syntax
Message ID:
David Nicol <> writes:

> it's not about $foo->@*
> it's about $foo->{bar}->baz(27, flurg => gnar_now())->[4]->@*
> at the end of a long chain of stuff eventually yielding a reference,
> sometimes you want to get the whole array, or a slice of it, and currently
> you need to back up and enclose the whole thing.

Yes, that is quite a burden, assuming you still use butterflies :)

Seriously, this is a strong indication of strictly left-to-right code
writing, not knowing beforehand what you want to do with that big
expression. Makes me frown.

> What we've just set up is the filling of the holes left in the current
> incomplete postfix dereference syntax, which allows only scalar element
> accesses.

Unbiased opinion: I do not doubt it fits in somewhere, my question was
whether it is worth the efforts given that it seems to add to
implementation and maintenance complexity, and potential user confusion.

Personal opinion: Since we have $aref->[1], $aref->[] makes sense to
mean the whole array. Likewise, $href->{foo}, $href->{}. But all other
examples I've seen of postfix dereference syntax seem rather contrived
to me. Why would you ever write $$foo->$* instead of $$$foo or ${$$foo}?
How often would you need $foo->\*? blah->&*?

-- Johan

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