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

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.

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

    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.

      > with the sigils I would still have to make distinction between a hash and a hash ref

      why??? €arr is an arr_ref ¥hash is a hash_ref nothing else. You wouldn't need to use @arr and %hash anymore (but you still could, if you want, it's compatible)

      > the only thing I would save is an ocassional -> or %{}

      well following PBP I always try to postfix references with _ref, or sometimes with "_aref", "_href" and "_cref". With more sigils there is no need for this anymore. And "occasional" @{} are really ugly to read.

      what is easier to read and maintain?

      for $x ( @{ $hash_ref->{k1}[2] } { ...}

      or

       for $x ( @¥hash{k1}[2] ) { ... }

      as a subconscious proof of bad maintainability I forgot a paren in the first example.

      You are already used to all these occasional extra symbols, but try to think about beginners who struggle to understand them and eventually switch to other languages.

      I can understand that symbols beyond char 127 are not optimal, but the perlparser is so overloaded with antique features and patches that you can't move a millimeter anymore. Just have a look at how complex it is to allow slices with hash- and array-refs! Slicing with Arrow-Operator possible in 5.12?

      This could be cleaned up with € and ¥. And contrary to perl6 my approach is still compatible, because you can transform them back into standard perl5.

      Cheers Rolf

        Contrary to Perl 6 my approach is still compatible, because you can transform them back into standard Perl 5.

        ... until the first time you run into a precedence problem, for example with hash or list slices.

        Waitasecond. So is your €arr the array referenced by $arr or the array @arr or what??? Or is it a whole different variable? In that case what does each of those mean?

        €one = @two; @one = €two; @one = @two; €one = €two; €one = \@two;
        The first is making an alias €one to the array @two? The second copying all values referenced by €two to @one? The third copying all elements of @two to @one? The fourth setting €one to point to the same array €two points to? The fifth god only knows what?

        This is one of the cases when I disagree with PBP (it's allowed), I do not use any such suffixes and do not ever remember being bitten by that.

        An ocassional @{} is necessary. Just as is an ocassional ( ) in expressions. Suppose you have this @¥hash{foo,bar}[2], what does the @ belong to? Is it @{¥hash{foo,bar}}[2] or @{¥hash{foo,bar}[2]}? Do we want the second element of the array referenced by the value of the ('foo'.$;.'bar') key of the hash referenced by ¥hash or the array referenced by the second element of the hash slice?

        I would not worry about what character to use, I'd rather worry about what are all the rules governing the intended use and whether the result is not way too complex.

        P.S.: You said you are sometimes using _cref ... looks like you'd need (at least) one more sigil. For the coderefs. And then scalar refs and maybe object refs ...