| [reply] |
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.
| [reply] [d/l] [select] |
I can tell you feel strongly about it, but I remain utterly and absolutely unconvinced that Perl needs to add more sigils in order to stay relevant. In fact, I believe that that would be going in exactly the wrong direction. Perl should drop sigils entirely. That would do a lot to convince the rest of the programming world that Perl is, or even could be, relevant.
(Of course, making such a change would entail changing other aspects of the language, such as context. But that would be OK, imho. Whatever is necessary to kill the sigil silliness.)
Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.
| [reply] |