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

&take returns 0, not the value taken in Rakudo #2959

Closed
p6rt opened this issue Nov 5, 2012 · 5 comments
Closed

&take returns 0, not the value taken in Rakudo #2959

p6rt opened this issue Nov 5, 2012 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Nov 5, 2012

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

Searchable as RT115598$

@p6rt
Copy link
Author

p6rt commented Nov 5, 2012

From @masak

<brrt> basically, 'take' both yields its value and returns, right?
<brrt> so my $x = take 3; sets $x to 3?
<brrt> r​: my $x = take 3; say $x;
<masak> r​: my @​a = gather { say take 3 };
<p6eval> rakudo 64208d​: OUTPUT«0␤»
<masak> brrt​: that's interesting.
<masak> what does the 0 mean?
<masak> r​: my @​a = gather { say take 3; say take 42 };
<p6eval> rakudo 64208d​: OUTPUT«0␤0␤»
<masak> n​: my @​ = gather { say take 3; say take 42 };
<p6eval> niecza v22-16-g4c016f5​: OUTPUT«3␤42␤»
* masak submits rakudobug
<flussence> take returns 0?
<flussence> (sometimes?)
<masak> flussence​: in Rakudo, yes. in Niecza it gives back the value.
<masak> which seems much more useful.
<flussence> agreed
<brrt> masak​: returning the value is basically what is spec'-ed
<masak> S04​:735.
<masak> The value returned by the C<take> to the C<take>'s own context
is that same
<masak> returned argument (which is ignored when the C<take> is in
sink context).

@p6rt
Copy link
Author

p6rt commented Nov 5, 2012

From @jnthn

On Mon Nov 05 06​:04​:33 2012, masak wrote​:

<brrt> basically, 'take' both yields its value and returns, right?
<brrt> so my $x = take 3; sets $x to 3?
<brrt> r​: my $x = take 3; say $x;
<masak> r​: my @​a = gather { say take 3 };
<p6eval> rakudo 64208d​: OUTPUT«0␤»
<masak> brrt​: that's interesting.
<masak> what does the 0 mean?
<masak> r​: my @​a = gather { say take 3; say take 42 };
<p6eval> rakudo 64208d​: OUTPUT«0␤0␤»
<masak> n​: my @​ = gather { say take 3; say take 42 };
<p6eval> niecza v22-16-g4c016f5​: OUTPUT«3␤42␤»
* masak submits rakudobug
<flussence> take returns 0?
<flussence> (sometimes?)
<masak> flussence​: in Rakudo, yes. in Niecza it gives back the value.
<masak> which seems much more useful.
<flussence> agreed
<brrt> masak​: returning the value is basically what is spec'-ed
<masak> S04​:735.
<masak> The value returned by the C<take> to the C<take>'s own context
is that same
<masak> returned argument (which is ignored when the C<take> is in
sink context).

Fixed​:

my @​a = gather { my $x = take 3; say $x; }
3

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Nov 5, 2012

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

@p6rt
Copy link
Author

p6rt commented Nov 14, 2012

From @coke

On Mon Nov 05 13​:54​:40 2012, jnthn@​jnthn.net wrote​:

On Mon Nov 05 06​:04​:33 2012, masak wrote​:

<brrt> basically, 'take' both yields its value and returns, right?
<brrt> so my $x = take 3; sets $x to 3?
<brrt> r​: my $x = take 3; say $x;
<masak> r​: my @​a = gather { say take 3 };
<p6eval> rakudo 64208d​: OUTPUT«0␤»
<masak> brrt​: that's interesting.
<masak> what does the 0 mean?
<masak> r​: my @​a = gather { say take 3; say take 42 };
<p6eval> rakudo 64208d​: OUTPUT«0␤0␤»
<masak> n​: my @​ = gather { say take 3; say take 42 };
<p6eval> niecza v22-16-g4c016f5​: OUTPUT«3␤42␤»
* masak submits rakudobug
<flussence> take returns 0?
<flussence> (sometimes?)
<masak> flussence​: in Rakudo, yes. in Niecza it gives back the value.
<masak> which seems much more useful.
<flussence> agreed
<brrt> masak​: returning the value is basically what is spec'-ed
<masak> S04​:735.
<masak> The value returned by the C<take> to the C<take>'s own context
is that same
<masak> returned argument (which is ignored when the C<take> is in
sink context).

Fixed​:

my @​a = gather { my $x = take 3; say $x; }
3

Tagging testneeded.

/jnthn

Test added in S04-statements/gather.t

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Nov 14, 2012

@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