in reply to Re^13: Experimental features: autoderef vs postfix deref
in thread Experimental features: autoderef vs postfix deref

What is special about toplevel? Does that only work for push or everywhere?

lvalue = value; template

${ $foo->{bar} }{baz} = 4;

$foo->{bar}->{baz} = 4;

Replies are listed 'Best First'.
Re^15: Experimental features: autoderef vs postfix deref
by Anonymous Monk on Jul 14, 2015 at 02:33 UTC

    Does that template exist in the documentation? The one I cited does.

    Why not make your straw man ${ ${ $foo->{bar} }{baz} } = 4? A. Because that would be even more stupid.

    Why not just $foo->{bar}{baz} = 4; the way 90% of people write it? A. because that would highlight how verbosely hieroglyphic the postfix syntax is ->@*.

      Why not make your straw man ${ ${ $foo->{bar} }{baz} } = 4? A. Because that would be even more stupid.
      :-) OK, let's try:
      ${ $foo->{bar}{baz} } = 4:
      Still looks stupid?

      What about:

      @{ $foo->{bar}{baz} }[0, 5] = (3, 4);
      I guess, also too stupid?

      Let's try some more:

      @{ $foo->{bar}{baz} }{ 'John', 'Jane', 'Bill' } = ('Smith') x 3;
      Stupid?

      If not, then why

      ${ $foo->{bar} }{baz} = 4;
      becomes stupid? Maybe because you can actually avoid circumfix dereferencing here?

      Why not just $foo->{bar}{baz} = 4; the way 90% of people write it?
      That's what I'm asking. Why 90% of people try to avoid circumfix when they can?

        Why 90% of people try to avoid circumfix when they can?

        They're not "avoiding"; they just not adding what would be pointless.

        Just as those in favour of postfix deref won't add: $foo->{bar}->{baz}->$* = 4;, because that would be equally pointless.

        So, back to the real argument.

        When explicit dereferencing is actually required, is push @{ $foo->{bar}{baz} }, 4;

        Simpler, clearer, easier to scan and less ugly than push $foo->{bar}->{baz}->@*, 4;

        And clearly the answer is yes. /c