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

Can't map over a callable with a slurpy in Rakudo #2723

Closed
p6rt opened this issue Apr 24, 2012 · 5 comments
Closed

Can't map over a callable with a slurpy in Rakudo #2723

p6rt opened this issue Apr 24, 2012 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Apr 24, 2012

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

Searchable as RT112596$

@p6rt
Copy link
Author

p6rt commented Apr 24, 2012

From @masak

<grondilu> p6​: .say for map &sprintf.assuming("%x"), ^16;
<p6eval> ..rakudo b64c1e​: OUTPUT«This type cannot unbox to a native
integer [...]
<grondilu> this used to work fine :(
<moritz> when? and in which compiler?
<grondilu> I don't know exactly. Something like this was in my Digest module.
<moritz> I'm a bit surprised it ever worked
<moritz> because sprintf has a signature of ($format, *@​args)
<grondilu> so?
<grondilu> "%x" is a format, isn'it?
<moritz> yes, but what remains after the .assuming is applied is a
signature of (*@​args)
<moritz> and .map is sensitive to the arity of the block it operates on
<masak> so .map slurps all of the ^16
<grondilu> I don't give a block I give a function
<moritz> grondilu​: s/block/callable/ then
<moritz> well, it's the same as sprintf("%x', ^16)
<moritz> which should complain about excess arguments
<grondilu> hang on
<moritz> r​: say sprintf('%x', ^16)
<p6eval> rakudo b64c1e​: OUTPUT«0␤»
<masak> huh.
<moritz> it seems to just ignore all the other arguments
<moritz> the format tells it to print only one number
<moritz> so that's all it does
<masak> right.
<masak> there really should be a check there.
<masak> for too-many as well as too-few.
<moritz> masak​: yes, but we can't do that with our current factoring
<moritz> grondilu​: assuming just returns a callable with one argument curried
<moritz> now this should work​:
<moritz> r​: sub a($a, $b) { sprintf $a, $b }; .say for map
&a.assuming('%x'), ^16
<p6eval> rakudo b64c1e​: OUTPUT«This type cannot unbox to a native integer [...]
<grondilu> ah
<grondilu> There IS something wrong, isn't there?
<moritz> r​: .say for map -> *@​a { @​a } , ^16
<p6eval> rakudo b64c1e​: OUTPUT«This type cannot unbox to a native integer [...]
<moritz> grondilu​: yes, there's something wrong
* masak submits rakudobug
<moritz> grondilu​: and I believe I know what
<moritz> it's getting Inf as the parameter count
<moritz> and tries to unbox that as an integer
<grondilu> Are you going to add this in the test suite to avoid
degradation in future?
<grondilu> Because really​: it used to work.
<moritz> yes, but it relied on a bug
<moritz> I know how and why it used to work
<grondilu> ok
<moritz> but when we fix this bug, it won't work the way you want it to work
<grondilu> :(
<grondilu> why not??
<moritz> because the arity of the callable that you pass to .map
decides how many arguments maps passes to the callable
<moritz> and your takes as many arguments as it wants
<moritz> but let me propose
<moritz> r​: .say for map *.fmt('%x'), ^16
<p6eval> rakudo b64c1e​: OUTPUT«0␤1␤2␤3␤4␤5␤6␤7␤8␤9␤a␤b␤c␤d␤e␤f␤»
<grondilu> oh that's nice
<moritz> that works, will continue to work, and is even shorter :-)
<grondilu> thanks!
<grondilu> I totally forgot about the fmt method
* grondilu happily edits his Digest module :)

@p6rt
Copy link
Author

p6rt commented Nov 21, 2012

From @FROGGS

looks good now​:

<FROGGS> p6​: .say for map &sprintf.assuming("%x"), ^16;
<p6eval> niecza v22-36-g19fa03a​: OUTPUT«0␤»
<p6eval> ..rakudo bf472b​: OUTPUT«0␤1␤2␤3␤4␤5␤6␤7␤8␤9␤a␤b␤c␤d␤e␤f␤»

@p6rt
Copy link
Author

p6rt commented Nov 21, 2012

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

@p6rt
Copy link
Author

p6rt commented Mar 29, 2013

From @coke

On Wed Nov 21 10​:56​:47 2012, FROGGS.de wrote​:

looks good now​:

<FROGGS> p6​: .say for map &sprintf.assuming("%x"), ^16;
<p6eval> niecza v22-36-g19fa03a​: OUTPUT«0␤»
<p6eval> ..rakudo bf472b​: OUTPUT«0␤1␤2␤3␤4␤5␤6␤7␤8␤9␤a␤b␤c␤d␤e␤f␤»

Test added to S32-list/map.t - resolving ticket.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Mar 29, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant