Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whatever globbing in chained hash indexing #895

Closed
p6rt opened this issue Apr 16, 2009 · 8 comments
Closed

Whatever globbing in chained hash indexing #895

p6rt opened this issue Apr 16, 2009 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 16, 2009

Migrated from rt.perl.org#64768 (status was 'resolved')

Searchable as RT64768$

@p6rt
Copy link
Author

p6rt commented Apr 16, 2009

From @masak

$ perl6 -e 'my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say %h{*}[1].perl'
elements() not implemented in class 'Undef'
[...]

When this works, we'll want this to output '[2, 5]'.

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

From @bbkr

On Kiev build
$ perl6 -e 'my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say %h{*}[1].perl'
Method 'postcircumfix​:<[ ]>' not found for invocant of class 'Proxy'
  in main program body at line 1

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Mon Jul 12 06​:51​:06 2010, bbkr wrote​:

On Kiev build
$ perl6 -e 'my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say %h{*}
[1].perl'
Method 'postcircumfix​:<[ ]>' not found for invocant of class 'Proxy'
in main program body at line 1

new behavior​:

17​:13 <diakopter> r​: my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say %h{*}
[1].perl
17​:13 <p6eval> rakudo 024843​: OUTPUT«[4, 5, 6]␤»

@p6rt
Copy link
Author

p6rt commented Jul 9, 2012

From @pmichaud

After thinking about this a bit, I'm inclined to disagree with the
original ticket.

  my %h = 'foo' => [1,2,3], 'bar' => [4,5,6];

If %h{*} is analogous to @​array[*], then it returns a list (slice) of
all of the elements of %h. The .[1] should then return the second
element of this slice, which would be either [1,2,3] or [4,5,6]
depending on the order in which the values were returned from %h{*}.

The real way to grab the second element from each array in the hash
would be something like​:

  %h{*}».[1]

which would apply the .[1] to each array returned from the hash.
Unfortunately this also relies on "duck mapping" of the hyper as defined
in S03, which as yet is NYI in Rakudo. (And implementing S03's duck
mapping will require some refactoring of postcircumfix​:<[ ]> and
postcircumfix​:<{ }>.

To get the (2,5) expected from the original ticket likely requires
something like​:

  > my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say (.[1] for
%h{*}).perl
  (2, 5).list

The other possible mechanism for multidimensional slice subscripting is
defined in S09 using semicolons, as in something like %h{*;1}. However,
that requires declared dimensioned hashes and/or arrays (which the
example is not), and I'm not sure that syntax will work for mixed
hash/array structures.

So, we can either reject this ticket, or we can maybe convert it to a
ticket that notes that "duck mapping" of hypers is NYI in Rakudo
(although I'm not convinced that duck mapped hypers is the correct
solution to the overall problem with hypers).

Pm

@p6rt
Copy link
Author

p6rt commented Aug 16, 2015

From @FROGGS

So far this works​:
m​: my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say %h{*}»[1]
rakudo-moar f185e0​: OUTPUT«5 2␤»

But this does not​:
m​: my %h = 'foo' => [1,2,3], 'bar' => [4,5,6]; say %h{*}».[1]
rakudo-moar f185e0​: OUTPUT«Cannot find method 'postcircumfix​:<( )>'␤ in block <unit> at /tmp/WldouUReun​:1␤␤»

@p6rt
Copy link
Author

p6rt commented Mar 12, 2016

From @moritz

This has been implemented by now, presumably by lizmat.

Tested here​:
Raku/roast@5c4dafa3ab

@p6rt
Copy link
Author

p6rt commented Mar 12, 2016

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Mar 12, 2016
@p6rt p6rt added the Todo label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant