On Sat, Sep 27, 2008 at 12:31:08AM -0700, Vasily Chekalkin wrote:
> # New Ticket Created by  Vasily Chekalkin 
> # Please include the string:  [perl #59396]
> # in the subject line of all future correspondence about this issue. 
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59396 >
> 
> 
> Hello.
> 
> There is implementation of Hash.reverse
> 
> -- 
> Bacek

> diff --git a/languages/perl6/src/classes/Mapping.pir 
> b/languages/perl6/src/classes/Mapping.pir
> index ec9824f..7b9aace 100644
> --- a/languages/perl6/src/classes/Mapping.pir
> +++ b/languages/perl6/src/classes/Mapping.pir
> @@ -18,7 +18,7 @@ src/classes/Mapping.pir - Perl 6 hash class and related 
> functions
>      mappingproto = p6meta.'new_class'('Mapping', 'parent'=>'Hash Any')
>      p6meta.'register'('Hash', 'parent'=>mappingproto, 
> 'protoobject'=>mappingproto)
>      $P0 = get_hll_namespace ['Mapping']
> -    '!EXPORT'('keys kv values', $P0)
> +    '!EXPORT'('keys kv values reverse', $P0)
>  .end

It feels a little weird to have 'reverse' as an exported symbol
here.  Based on S29, the exports on 'reverse' mean that we get:

    my $str = 'abc';
    say reverse $str;              # cba
    say reverse $str, 5;           # 2abc

    my %hash = { a=>1, b=>2, c=>3 };
    say reverse %hash;             # 1   a\n2   b\n3   c\n
    say reverse %hash, 5;          # 5\na   1\nb   2\nc   3\n
                                   # note keys and values are not reversed

It just seems a bit odd to me that adding an extra argument causes
the meaning of 'reverse' to change for hashes and strings.

Pm

Reply via email to