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

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 ...

Replies are listed 'Best First'.
Re^6: Two more Features Perl 5 Maybe Needs
by LanX (Saint) on Dec 23, 2008 at 23:00 UTC
    No, it's not as complicated, €, ¥, £ and ¢ are currency symbols like $. A simple €arr is a scalar which is meant to hold a array_ref. It's identical to $arr! Unlike @arr which has another place in the symbol table, changing $arr also means changing €arr (or ¥arr, there is no typechecking *). Just the dereferencing syntax is different!
    €one = @two; @one = €two; @one = @two; €one = €two; €one = \@two; # is translated to $one = @two; @one = $two; @one = @two; $one = $two; $one = \@two;

    > Suppose you have this @¥hash{foo,bar}[2], what does the @ belong to? Is it @{¥hash{foo,bar}}[2] or @{¥hash{foo,bar}[2]}?

    the grouping of @€[..] is indented to be the opposit of @$[..], that means "listyfy" the biggest possible part, so it is @ {¥hash{foo,bar}[2]}.

    Think of it as

    sub aref2list ($) { return @{ $_[0] } } aref2list($hash->{foo,bar}[2]);

    The first alternative can be achieved as you typed it @{¥hash{foo,bar}}[2] which is identical with  @{ $hash->{foo,bar} }[2]. You can still use curlies for grouping, just the default grouping was changed. and if you want the old default behavior just write  @$hash{foo,bar}[2].

    Some remarks::

    1. I'd prefer to get rid of this old multi-dimensional hash syntax. With the new sigils there is no need anymore to use it. If we abandon it we can use the notation for slices.

    2. I'm not sure anymore if using @€ and %¥ this way is a good choice ... maybe better *€ and *¥, which is closer to perl6. ( or identical? I can't tell ...)

    > P.S.: You said you are sometimes using _cref ... looks like you'd need (at least) one more sigil.

    Yes, and I think ¢ is a good choice! 8 ) but the benefit of writing  ¢coderef(paras) instead of  $coderef->(paras) alone doesn't justify this discussion. That's why I'm focussing on arrays and hashes!

    Cheers Rolf

    PS: There seems to be a bug in the board's software. Occasionally previewing ¥ is translated to Â¥ by the cgi. Can't reproduce when and why! I have to correct every symbol manually! : (

    UPDATE: (*) To be precise, i can't realize typechecking with a codefilter, but I think it's worth thinking about a runtime typechecking and warning, if the scalar in €arr is an array_ref or not. A (slow) solution could be achieved with tieing the scalar and checking with ref when STORE is called.