in reply to Two more Features Perl 5 Maybe Needs
in thread Five Features Perl 5 Needs Now

Yeah, those two things are surely necessary to keep Perl 5 relevant.
</sarcasm>

  • Comment on Re: Two more Features Perl 5 Maybe Needs

Replies are listed 'Best First'.
Re^2: Two more Features Perl 5 Maybe Needs
by LanX (Saint) on Dec 21, 2008 at 02:48 UTC
    32,300 Results for "perl beginner problem nested arrays".

    </argument sarcasm=off>

        I don't know how to produce an accurate google statistic for the biggest beginner problem. You might also search for "arrays of arrays" (1490 results), or compare the stats for other common obstacles like "list context".

        But I bet the non-reference character of @array will be the number one or at least on top three.

        Almost every propaganda against perl I've seen so far lists this as a problem, and I haven't met any perl hacker til now, who didn't run into this trap.

        I just wanted to propose extended sigils helping to destroy this argument without breaking compability like perl6 does.

        And these sigils can be seen as a replacement of the PBP-rule to flag every reference variable with a trailing "_ref".

        Which symbols to choose for these sigils is a matter of debate, since the characters less than 128 are already overloaded with syntactical meaning. Especially € is mapped on different positions.

        UPDATE:

        I know some people who decided only to use refs of arrays and hashes to avoid these problems. I tried this myself, but it's not that easy. e.g. you cant write push $arr_ref, expr;, slices with -> are not possible $arr_ref->[1..5] and nested structures need to be put in parens to get the listform:
        for ( @{ $arr_ref->[idx1][idx2] } ) { ... }
        compare this with
        push €arr, expr; # (*) €arr[1..5]; for ( @€arr[idx1][idx2] ) { ... };
        (*) prototype mechanism has to be extended for this.