Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

by Perlbotics (Archbishop)
on Sep 10, 2020 at 19:24 UTC ( [id://11121570]=note: print w/replies, xml ) Need Help??


in reply to What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

I would barter all of these improvements for a less noisy but performant elemement accessor syntax:

i.e.

$it->{$key}->[$idx]->{section}->[$i]->{'some.doc'}->method1()->[sub1 +(5)]->method2($x); # or $it->{$key}[$idx]{section}[$i]{'some.doc'}->method1()->[sub1(5)]->me +thod2($x);

becomes something like:

$it->@( $key $idx section $i some.doc method1() sub1(5) method2($x) +);
or something smarter...

Disambiguation: If the actual element is blessed and can('method1'), it is invoked. Otherwise it is treated as a function call (:: might be used for further disambiguation).

I.e. similar to Data::Diver, just more efficient together with a pragma or other method to control auto-vivification. Yes, I am aware, that I could build something similar as a module, but it would be pure Perl.

Replies are listed 'Best First'.
Re^2: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by tobyink (Canon) on Sep 11, 2020 at 08:44 UTC

    Potentially ambiguous. What if $it->{$key} returns a blessed scalarref that overloads both @{} and %{}? Is the next step $it->{$key}[$idx] or $it->{$key}{$idx}?

      Good point. That's the drawback where edge-cases can add a lot of complexity.
      Perhaps throw an exception? Allow annotations on how to resolve (see below)? Implicit rules? — down the rabbit hole of smart-matching :(

      Example: Resolve overloaded @{} by using the standard notation as a hint like so?

      $it->@( $key [$idx] section $i some.doc method1() sub1(5) method2($x) +);
      It should be rarely needed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found