in reply to Five Features Perl 5 Needs Now

May I suggest two more possible improvements?

6. Builtin easy aliasing of lexicals:

something like:

sub get_hash { my %h; ... ;return \%h} my (*h2)= get_hash(); #I'm not sure about the best syntax print keys %h2;
such that beginners don't need to learn dereferencing straight away, just because they have nested data structures or want to return them from a sub.

7. Introducing optional extra Sigils for Hashes and Arrays which behave like the sigils in perl6, that means representing the reference not the list!

¥hash{key1}{key2}=$hash{key1}{key2}; €arr1[0]=€arr2; # => €arr1[0][0] == €arr2[0]; push €arr1[0], "string"; # => pop €arr2 == "string";
I know finding appropriate symbols in all charsets is complicated, but this could facilitate forward compability to perl6, if perl6 could then use these symbols as alternative aliases for @ and %.

just ideas ...

Cheers Rolf

Replies are listed 'Best First'.
Re: Two more Features Perl 5 Maybe Needs
by Jenda (Abbot) on Dec 21, 2008 at 23:34 UTC

    I most wholeheartedly agree with the 6., but do not see any need for the 7. The sigils we have are great, the system works and makes sense (and the change in the system of sigils is gonna cause a heluva lot of wasted time while seasoned Perl5 developers struggle to relearn sigils working the Perl6 way), but there is no need to complicate it any more. BTW, IMnsHO the changes to sigils and the concatenation and method call operators were both bad ideas.

    Besides, after a lot of thinking, I (hopefully correctly) inferred the intended meaning of the array examples, but still have no idea whatsoever what did you mean by the first line.

      The new sigils represent all references. The currency symbols are just other representations of $.

      So ¥hr={} means $hr={} and analogous with €ar=[] but the handling is easier.

      --- New --- Internally ¥hr == $hr ¥hr{k1} == $hr->{k1} ¥hr{k1}=¥hr2 == $hr->{k1} = $hr2 keys ¥hr == keys %$hr keys ¥hr{k1}{k2} == keys %{ $hr->{k1}{k2} } print €ar[1] == print $ar->[1] print @€ar[1] == print @{ $ar->[1] }
      hope that's clearer ...

      Tomorrow I'll try to hack a codefilter as a proof of concept.

      Actually if point 7 is realized, one don't really need point 6 any more ...

      sub foo { return ( [], {} ) } my (€ar,¥hr) = foo();

      But your right the first line was misleading! ... I got confused with the new idea of compability to perl6 syntax...but now I think that's far to complicated to achieve with the perl5 parser.

        The additional sigils complicate Perl, the aliases would simplify it. With the aliases I could declare a hash as being the same as the one referenced by some complicated expression, with the sigils I would still have to make distinction between a hash and a hash ref and the only thing I would save is an ocassional -> or %{}. For the price of introducing another special character.

        Lexical aliases should have been in the language since 5.0. Additional sigils should not be there at all. IMHO of course.

Re: Two more Features Perl 5 Maybe Needs
by jdporter (Paladin) on Dec 21, 2008 at 01:48 UTC

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

      32,300 Results for "perl beginner problem nested arrays".

      </argument sarcasm=off>