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

[]{} method2sub broke *[0]([1, 2, 3]) #3241

Closed
p6rt opened this issue Sep 26, 2013 · 6 comments
Closed

[]{} method2sub broke *[0]([1, 2, 3]) #3241

p6rt opened this issue Sep 26, 2013 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Sep 26, 2013

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

Searchable as RT120025$

@p6rt
Copy link
Author

p6rt commented Sep 26, 2013

From @lizmat

TimToady pointed out that my work on converting [] and {} accesses to sub calls, rather than method calls, had one more casualty​:

*[0]([1, 2, 3])

This is tested in t/spec/S02-types/whatever.t, line 252 and currently fudged.

The suggested change in whatever_curry did not give the right result. And now I'm in here over my head, so I'm submitting a bug report as promised.

Liz

[18​:53​:51] <TimToady> lizmat​: did you notice that the subscripting change broke *.[], *.<>, and *.{}
[18​:54​:21] <lizmat> TimToady​: no, don't think so
[18​:54​:55] <lizmat> I fudged a number of tests, but I don't recall fudging any .[] related tests
[18​:54​:56] <TimToady> nr​: my @​a = [1,2,3],[4,5,6],[7,8,9]; say @​a.map​: *.[2]
[18​:54​:59] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«3 6 9␤»
[18​:55​:00] <camelia> ..rakudo 50a57d​: OUTPUT«Index out of range. Is​: 2, should be in 0..0␤ in method <anon> at src/gen/CORE.setting​:11768␤ in any at src/gen/Metamodel.nqp​:2671␤ in any find_method_fallback at src/gen/Metamodel.nqp​:2659␤ in any find_method at src/gen/Metamodel.nqp​:946␤ in method reify…»
[19​:09​:11] <lizmat> jnthn​: I'm not sure how to fix .[] etc., any pointers ?
[19​:11​:03] <lizmat> aaahhhhh… I completely missed that TimToady meant Whatever.[]
[19​:11​:16] <lizmat> yes, that broke​: simplest case
[19​:11​:37] <lizmat> nr say *[0](1,2,3)
[19​:11​:42] <lizmat> nr​: say *[0](1,2,3)
[19​:11​:45] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled exception​: Excess arguments to ANON, used 1 of 3 positionals␤ at /tmp/GbWfbqMj6Y line 0 (ANON @​ 1) ␤ at /tmp/GbWfbqMj6Y line 1 (mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583 (ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE…»
[19​:11​:45] <camelia> ..rakudo 50a57d​: OUTPUT«No such method 'postcircumfix​:<( )>' for invocant of type 'Whatever'␤ in block at /tmp/IcpYdTyvhm​:1␤␤»
[19​:12​:04] <jnthn> lizmat​: yeah
[19​:12​:10] <jnthn> lizmat​: See Actions.pm, whatever_curry
[19​:12​:16] lizmat checks
[19​:12​:31] <jnthn> lizmat​: Near the top it OKs infix, prefix and postfix. Try adding postcircumfix to that list.
[19​:13​:36] <lizmat> I guess I should follow the callmethod value, right?
[19​:14​:13] <jnthn> ?
[19​:14​:25] <jnthn> no, inside whatever_curry
[19​:14​:38] <jnthn> (nqp​::index($past.name, '&infix​:') == 0 ||
[19​:14​:38] <jnthn> nqp​::index($past.name, '&prefix​:') == 0 ||
[19​:14​:38] <jnthn> nqp​::index($past.name, '&postfix​:') == 0 ||
[19​:14​:42] <lizmat> ahhhh ok
[19​:14​:42] <jnthn> After that
[19​:16​:21] <lizmat> compiling and testing
[19​:19​:26] <TimToady> using index to test for prefix bothers me, since it'll scan uselessly whenever it doesn't match
[19​:20​:49] moritz waits for masak++ to construct a bug report that involves a variable named 'something&infix​:bla' which shouldn't be treated as an infix, but is
[19​:21​:11] <masak> :P
[19​:21​:21] <TimToady> well, the == 0 prevents that, but it's just the waste that bothers me
[19​:24​:07] <TimToady> it's like using a pile-driver to squash a bug, and after doing it 50 times, then checking to see if you were successful the first time
[19​:25​:33] <moritz> might still be faster than nqp​::eq(nqp​::substr($past.name, 0, nqp​::chars('&infix​:')), '&infix​:')
[19​:25​:38] <TimToady> and a smart index might even have set up Boyer-Moore tables on the assumption it was going to scan
[19​:26​:18] <TimToady> sure would be nice if we could write Perl 6 in Perl 6 :)
[19​:27​:11] <TimToady> then it's just /^ '&' [ in | pre | post 'circum'? ] fix '​:' / :)
[19​:27​:58] <lizmat> $ perl6 --ll-exception -e 'say *[0](1,2,3)'
[19​:27​:58] <lizmat> Too many positional parameters passed; got 3 but expected 1
[19​:28​:30] <lizmat> full stack trace​: https://gist.github.com/lizmat/6717575
[19​:28​:35] <lizmat> the error changed
[19​:28​:54] <lizmat> but I have no idea where that code lives
[19​:29​:40] <FROGGS> lizmat​: maybe look at the ast
[19​:30​:38] <TimToady> lizmat​: src/Perl6/Actions.nqp sez a recursive grep
[19​:33​:00] <lizmat> sanity check​: *[0](1,2,3,4,5) should return the first element of the (1,2,3,4,5) parcel, right ?
[19​:35​:02] <TimToady> nr​: say (1,2,3,4,5)[0]
[19​:35​:05] <camelia> rakudo 50a57d, niecza v24-95-ga6d4c5f​: OUTPUT«1␤»
[19​:35​:08] <TimToady> so it would seem
[19​:35​:23] <lizmat> right *phew*
[19​:35​:35] <TimToady> so *() has to be exempted from the postcirumfixes for *
[19​:36​:05] <TimToady> unless we force people to say (*[0])(1,2,3,45)
[19​:36​:16] <lizmat> trying that
[19​:36​:18] <TimToady> if we decide there's a use case for *.()
[19​:36​:32] <TimToady> which arguably there probably is
[19​:36​:55] <TimToady> map​: *.() should invoke each of a list of invokables
[19​:37​:23] <TimToady> so I'm inclined to not make *() an exception, and force people to say (*[0])(1,2,3,4,5) if that's what they mean
[19​:38​:06] <TimToady> in that case, *[0](1,2,3,4,5) means { $_.[0].(1,2,3,4,5) } (as a WhateverCode)
[19​:38​:17] <TimToady> that feels cleaner to me
[19​:38​:43] <TimToady> the use case for callinging a WhateverCode directly is minimal
[19​:38​:50] <TimToady> *inginging
[19​:39​:14] lizmat feels she no longer has to duck
[19​:39​:36] <TimToady> nr​: say *[0](1,2,3,4,5).WHAT
[19​:39​:36] <lizmat> as in​: this is way over my head
[19​:39​:38] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled exception​: Excess arguments to ANON, used 1 of 5 positionals␤ at /tmp/vU2WHEK3m3 line 0 (ANON @​ 1) ␤ at /tmp/vU2WHEK3m3 line 1 (mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583 (ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE…»
[19​:39​:39] <camelia> ..rakudo 50a57d​: OUTPUT«No such method 'postcircumfix​:<( )>' for invocant of type 'Whatever'␤ in block at /tmp/uP5CQeMuln​:1␤␤»
[19​:40​:06] <TimToady> n​: say (*[0](1,2,3,4,5)).WHAT
[19​:40​:08] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled exception​: Excess arguments to ANON, used 1 of 5 positionals␤ at /tmp/zSzO4DEzSC line 0 (ANON @​ 1) ␤ at /tmp/zSzO4DEzSC line 1 (mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583 (ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE…»
[19​:40​:28] <TimToady> I guess niecza exempts .() though
[19​:41​:07] <TimToady> n​: say (*(1,2,3,4,5)).WHAT
[19​:41​:09] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled exception​: Unable to resolve method postcircumfix​:<( )> in type Whatever␤ at /tmp/JqJTGWQeaz line 1 (mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583 (ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4584 (module-C…»
[19​:49​:02] <TimToady> n​: say ({.(1,2,3,4,5)}).WHAT
[19​:49​:04] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«(Block)␤»
[19​:49​:23] TimToady thinks *(1,2,3,4,5) should mean that
[19​:49​:39] <TimToady> well, except it's a WhateverCode
[19​:51​:15] <masak> TimToady​: *(1,2,3,4,5) looks like -> &f { &f(1,2,3,4,5) } to me.
[19​:51​:40] <masak> oh wait, we're saying the same thing, aren't we?
[19​:51​:47] <TimToady> yes, though I just wrote it {.()}
[19​:52​:36] <TimToady> so I flipflopped on my answer to lizmat++ and don't think .() should be an exception under Whatever
[19​:53​:06] <lizmat> .oO( lalaalalalala I'm not listening ) :-)
[19​:53​:49] <TimToady> but you BROKE it! WAAAH! :P
[19​:54​:07] <lizmat> may I plead insanity ?
[19​:54​:54] <TimToady> as long as you don't plead ultro-low-frequency EM
[19​:55​:03] <TimToady> *ultra
[19​:55​:17] <lizmat> My Hero!
[19​:55​:55] <TimToady> but in that case someone needs to file a bug
[19​:56​:16] <lizmat> .oO( I was suddenly reminded of http://en.wikipedia.org/wiki/My_Hero_(UK_TV_series) )
[19​:57​:08] TimToady looks around for an anti-hero to file the bug report for all the wrong reasons...
[20​:00​:59] <lizmat> I will file one if I can't get it fixed

@p6rt
Copy link
Author

p6rt commented Apr 13, 2014

From @Mouq

On Thu Sep 26 11​:17​:22 2013, elizabeth wrote​:

TimToady pointed out that my work on converting [] and {} accesses to
sub calls, rather than method calls, had one more casualty​:

*[0]([1, 2, 3])

This is tested in t/spec/S02-types/whatever.t, line 252 and currently
fudged.

Works now​:

$ perl6 -e'say *[0]([1, 2, 3])'
1

The suggested change in whatever_curry did not give the right result.
And now I'm in here over my head, so I'm submitting a bug report as
promised.

Liz

[18​:53​:51] <TimToady> lizmat​: did you notice that the subscripting
change broke *.[], *.<>, and *.{}
[18​:54​:21] <lizmat> TimToady​: no, don't think so
[18​:54​:55] <lizmat> I fudged a number of tests, but I don't
recall fudging any .[] related tests
[18​:54​:56] <TimToady> nr​: my @​a = [1,2,3],[4,5,6],[7,8,9]; say
@​a.map​: *.[2]
[18​:54​:59] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«3 6 9␤»
[18​:55​:00] <camelia> ..rakudo 50a57d​: OUTPUT«Index out of range.
Is​: 2, should be in 0..0␤ in method <anon> at
src/gen/CORE.setting​:11768␤ in any at src/gen/Metamodel.nqp​:2671␤
in any find_method_fallback at src/gen/Metamodel.nqp​:2659␤ in any
find_method at src/gen/Metamodel.nqp​:946␤ in method reify…»
[19​:09​:11] <lizmat> jnthn​: I'm not sure how to fix .[] etc., any
pointers ?
[19​:11​:03] <lizmat> aaahhhhh… I completely missed that TimToady
meant Whatever.[]
[19​:11​:16] <lizmat> yes, that broke​: simplest case
[19​:11​:37] <lizmat> nr say *[0](1,2,3)
[19​:11​:42] <lizmat> nr​: say *[0](1,2,3)
[19​:11​:45] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled
exception​: Excess arguments to ANON, used 1 of 3 positionals␤ at
/tmp/GbWfbqMj6Y line 0 (ANON @​ 1) ␤ at /tmp/GbWfbqMj6Y line 1
(mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583
(ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE…»
[19​:11​:45] <camelia> ..rakudo 50a57d​: OUTPUT«No such method
'postcircumfix​:<( )>' for invocant of type 'Whatever'␤ in block at
/tmp/IcpYdTyvhm​:1␤␤»
[19​:12​:04] <jnthn> lizmat​: yeah
[19​:12​:10] <jnthn> lizmat​: See Actions.pm, whatever_curry
[19​:12​:16] lizmat checks
[19​:12​:31] <jnthn> lizmat​: Near the top it OKs infix, prefix and
postfix. Try adding postcircumfix to that list.
[19​:13​:36] <lizmat> I guess I should follow the callmethod value,
right?
[19​:14​:13] <jnthn> ?
[19​:14​:25] <jnthn> no, inside whatever_curry
[19​:14​:38] <jnthn> (nqp​::index($past.name,
'&infix​:') == 0 ||
[19​:14​:38] <jnthn> nqp​::index($past.name,
'&prefix​:') == 0 ||
[19​:14​:38] <jnthn> nqp​::index($past.name,
'&postfix​:') == 0 ||
[19​:14​:42] <lizmat> ahhhh ok
[19​:14​:42] <jnthn> After that
[19​:16​:21] <lizmat> compiling and testing
[19​:19​:26] <TimToady> using index to test for prefix bothers me,
since it'll scan uselessly whenever it doesn't match
[19​:20​:49] moritz waits for masak++ to construct a bug report
that involves a variable named 'something&infix​:bla' which shouldn't
be treated as an infix, but is
[19​:21​:11] <masak> :P
[19​:21​:21] <TimToady> well, the == 0 prevents that, but it's just
the waste that bothers me
[19​:24​:07] <TimToady> it's like using a pile-driver to squash a
bug, and after doing it 50 times, then checking to see if you were
successful the first time
[19​:25​:33] <moritz> might still be faster than
nqp​::eq(nqp​::substr($past.name, 0, nqp​::chars('&infix​:')), '&infix​:')
[19​:25​:38] <TimToady> and a smart index might even have set up
Boyer-Moore tables on the assumption it was going to scan
[19​:26​:18] <TimToady> sure would be nice if we could write Perl 6
in Perl 6 :)
[19​:27​:11] <TimToady> then it's just /^ '&' [ in | pre | post
'circum'? ] fix '​:' / :)
[19​:27​:58] <lizmat> $ perl6 --ll-exception -e 'say *[0](1,2,3)'
[19​:27​:58] <lizmat> Too many positional parameters passed; got 3
but expected 1
[19​:28​:30] <lizmat> full stack trace​:
https://gist.github.com/lizmat/6717575
[19​:28​:35] <lizmat> the error changed
[19​:28​:54] <lizmat> but I have no idea where that code lives
[19​:29​:40] <FROGGS> lizmat​: maybe look at the ast
[19​:30​:38] <TimToady> lizmat​: src/Perl6/Actions.nqp sez a recursive
grep
[19​:33​:00] <lizmat> sanity check​: *[0](1,2,3,4,5) should return
the first element of the (1,2,3,4,5) parcel, right ?
[19​:35​:02] <TimToady> nr​: say (1,2,3,4,5)[0]
[19​:35​:05] <camelia> rakudo 50a57d, niecza v24-95-ga6d4c5f​:
OUTPUT«1␤»
[19​:35​:08] <TimToady> so it would seem
[19​:35​:23] <lizmat> right *phew*
[19​:35​:35] <TimToady> so *() has to be exempted from the
postcirumfixes for *
[19​:36​:05] <TimToady> unless we force people to say
(*[0])(1,2,3,45)
[19​:36​:16] <lizmat> trying that
[19​:36​:18] <TimToady> if we decide there's a use case for *.()
[19​:36​:32] <TimToady> which arguably there probably is
[19​:36​:55] <TimToady> map​: *.() should invoke each of a list of
invokables
[19​:37​:23] <TimToady> so I'm inclined to not make *() an exception,
and force people to say (*[0])(1,2,3,4,5) if that's what they mean
[19​:38​:06] <TimToady> in that case, *[0](1,2,3,4,5) means {
$_.[0].(1,2,3,4,5) } (as a WhateverCode)
[19​:38​:17] <TimToady> that feels cleaner to me
[19​:38​:43] <TimToady> the use case for callinging a WhateverCode
directly is minimal
[19​:38​:50] <TimToady> *inginging
[19​:39​:14] lizmat feels she no longer has to duck
[19​:39​:36] <TimToady> nr​: say *[0](1,2,3,4,5).WHAT
[19​:39​:36] <lizmat> as in​: this is way over my head
[19​:39​:38] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled
exception​: Excess arguments to ANON, used 1 of 5 positionals␤ at
/tmp/vU2WHEK3m3 line 0 (ANON @​ 1) ␤ at /tmp/vU2WHEK3m3 line 1
(mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583
(ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE…»
[19​:39​:39] <camelia> ..rakudo 50a57d​: OUTPUT«No such method
'postcircumfix​:<( )>' for invocant of type 'Whatever'␤ in block at
/tmp/uP5CQeMuln​:1␤␤»
[19​:40​:06] <TimToady> n​: say (*[0](1,2,3,4,5)).WHAT
[19​:40​:08] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled
exception​: Excess arguments to ANON, used 1 of 5 positionals␤ at
/tmp/zSzO4DEzSC line 0 (ANON @​ 1) ␤ at /tmp/zSzO4DEzSC line 1
(mainline @​ 3) ␤ at /home/p6eval/niecza/lib/CORE.setting line 4583
(ANON @​ 3) ␤ at /home/p6eval/niecza/lib/CORE…»
[19​:40​:28] <TimToady> I guess niecza exempts .() though
[19​:41​:07] <TimToady> n​: say (*(1,2,3,4,5)).WHAT
[19​:41​:09] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«Unhandled
exception​: Unable to resolve method postcircumfix​:<( )> in type
Whatever␤ at /tmp/JqJTGWQeaz line 1 (mainline @​ 3) ␤ at
/home/p6eval/niecza/lib/CORE.setting line 4583 (ANON @​ 3) ␤ at
/home/p6eval/niecza/lib/CORE.setting line 4584 (module-C…»
[19​:49​:02] <TimToady> n​: say ({.(1,2,3,4,5)}).WHAT
[19​:49​:04] <camelia> niecza v24-95-ga6d4c5f​: OUTPUT«(Block)␤»
[19​:49​:23] TimToady thinks *(1,2,3,4,5) should mean that
[19​:49​:39] <TimToady> well, except it's a WhateverCode
[19​:51​:15] <masak> TimToady​: *(1,2,3,4,5) looks like -> &f {
&f(1,2,3,4,5) } to me.
[19​:51​:40] <masak> oh wait, we're saying the same thing, aren't
we?
[19​:51​:47] <TimToady> yes, though I just wrote it {.()}
[19​:52​:36] <TimToady> so I flipflopped on my answer to lizmat++ and
don't think .() should be an exception under Whatever
[19​:53​:06] <lizmat> .oO( lalaalalalala I'm not listening ) :-)
[19​:53​:49] <TimToady> but you BROKE it! WAAAH! :P
[19​:54​:07] <lizmat> may I plead insanity ?
[19​:54​:54] <TimToady> as long as you don't plead ultro-low-
frequency EM
[19​:55​:03] <TimToady> *ultra
[19​:55​:17] <lizmat> My Hero!
[19​:55​:55] <TimToady> but in that case someone needs to file a bug
[19​:56​:16] <lizmat> .oO( I was suddenly reminded of
http://en.wikipedia.org/wiki/My_Hero_(UK_TV_series) )
[19​:57​:08] TimToady looks around for an anti-hero to file the bug
report for all the wrong reasons...
[20​:00​:59] <lizmat> I will file one if I can't get it fixed

It seems most of this conversation is about the behaviour of *(). I think a different report should be filed for *.() or the title of this report be changed. As an aside, what curries into a WhateverCode should probably be written in the spec somewhere…

@p6rt
Copy link
Author

p6rt commented Apr 13, 2014

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

@p6rt
Copy link
Author

p6rt commented Oct 25, 2014

From @usev6

On Sat Apr 12 19​:55​:27 2014, Mouq wrote​:

On Thu Sep 26 11​:17​:22 2013, elizabeth wrote​:

TimToady pointed out that my work on converting [] and {} accesses to
sub calls, rather than method calls, had one more casualty​:

*[0]([1, 2, 3])

This is tested in t/spec/S02-types/whatever.t, line 252 and currently
fudged.

Works now​:

$ perl6 -e'say *[0]([1, 2, 3])'
1

[...]
It seems most of this conversation is about the behaviour of *(). I
think a different report should be filed for *.() or the title of this
report be changed. As an aside, what curries into a WhateverCode
should probably be written in the spec somewhere…

Since said test runs fine and is no longer fudged, I'm closing this ticket.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 25, 2014

From @usev6

On Sat Apr 12 19​:55​:27 2014, Mouq wrote​:

On Thu Sep 26 11​:17​:22 2013, elizabeth wrote​:

TimToady pointed out that my work on converting [] and {} accesses to
sub calls, rather than method calls, had one more casualty​:

*[0]([1, 2, 3])

This is tested in t/spec/S02-types/whatever.t, line 252 and currently
fudged.

Works now​:

$ perl6 -e'say *[0]([1, 2, 3])'
1

[...]
It seems most of this conversation is about the behaviour of *(). I
think a different report should be filed for *.() or the title of this
report be changed. As an aside, what curries into a WhateverCode
should probably be written in the spec somewhere…

Since said test runs fine and is no longer fudged, I'm closing this ticket.

@p6rt
Copy link
Author

p6rt commented Oct 25, 2014

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

@p6rt p6rt closed this as completed Oct 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant