develooper Front page | perl.perl6.language | Postings from March 2009

Re: [perl #62528] Match.keys method returns nothing.

Thread Next
From:
Moritz Lenz
Date:
March 29, 2009 12:10
Subject:
Re: [perl #62528] Match.keys method returns nothing.
Message ID:
49CFC78A.2020901@faui2k3.org
Since afaict this is not specced, I'll hand that over to p6l.

Eric Hodges (via RT) wrote:
> use v6;
> 
> rule test {test};
> 
> "test" ~~ /<test>/;
> say '$/.keys => ', $/.keys.perl;
> say '%($/).keys => ', %($/).keys.perl;
> 
> # outputs
> # $/.keys => []
> # %($/).keys => ["test"]
>
> 
> Same could be said for .values and .kv
> 
> It would be very DWIM for it to act like a hash in these cases by default.

Actually I think it would DWIM more in the general case if Match.keys
(and .kv, .pairs, .values etc) would give a list of the array and hash
part, so $/.keys would be  @($/).keys, %($/).keys.
Your suggestion would be just a degenerate case of that.

Any thoughts on that?

Cheers,
Moritz

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About