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

Re: postfix dereference syntax

Thread Previous | Thread Next
David Nicol
July 5, 2013 19:10
Re: postfix dereference syntax
Message ID:
On Fri, Jul 5, 2013 at 10:24 AM, Father Chrysostomos <> wrote:
> rjbs:
>> Edge cases
> If foo->@* means @foo, then does foo->@*[0] mean @foo[0]?  That is
> useless if we have foo->@[0].
> If we have foo->@[0] and extend it to all sigils, we end up with:

the advantage of simply allowing postfix in addition to circumfix with
the same symbols
is, there are no other complications.

   @{foo} would be allowed to be written as foo@{}, and the other
accesses into it would remain the same.  foo@{}[0] is a slice with a
single element, foo${}[0] is an element access

> $_->*{foo} # means *$_{foo}

the glob referred to by the globref in $_ is considered as a hash and
we access the value in the slot named "foo" Adding the implied curlies
gives *{$_}{foo} and in simple postfix syntax that would be $_*{}{foo}

> $_->${foo} # means $$_{foo} (i.e., $_->{foo})
> $_->&(foo) # means $&_{foo} (i.e., $_->(foo))
> The last two are useless.  The dollar form steals existing syntax.

First one: $_ contains a hashref and we want to look up the thing in
the foo slot. We have the skinny arrow postfix syntax for this
already; simple postfix brackets would give yet another
way to fully spell it out: in addition to ${$_}{foo} and $_->{foo}
there would be $_${}{foo}

Second one: if we're trying to call the coderef in $_ with an argument
of foo, &{$_}(foo), the circumfix ampersand dereference could become
postfix as $_&{}(foo).

if the empty curlies become optional, that would give a tight-binding
prefix sigil, a loose-binding postfix sigil, and circumfix (prefix
plus curlies) for when you need an intermediate grouping.

@foo and foo@  would mean the same thing. @foo@ would continue to be nonsense.
$foo[0] could get written foo$[0].

>  *$_{foo}

  could be written as $_*{foo}

> $_->{foo}

  could be written as $_${foo}

> $_->(foo)

  could be written as $_&(foo)

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