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

'state' initializers do not have START semantics in Rakudo #2530

Closed
p6rt opened this issue Oct 24, 2011 · 5 comments
Closed

'state' initializers do not have START semantics in Rakudo #2530

p6rt opened this issue Oct 24, 2011 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 24, 2011

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

Searchable as RT102070$

@p6rt
Copy link
Author

p6rt commented Oct 24, 2011

From @masak

<tadzik> nom​: sub foo { state $a = 5; say $a++ }; foo; foo; foo #state NYI?
<p6eval> nom 1fd3f8​: OUTPUT«5␤5␤5␤»
<tadzik> heh, ok
<tadzik> or am I doing it wrong?
<benabik> tadzik​: I'm guessing that state $a = 5 is either wrong in
nom or not doing what you expect.
<tadzik> I suppose so
<benabik> nom​: sub foo { state $a; BEGIN { $a = 5 }; say $a++ }; foo; foo; foo
<p6eval> nom 1fd3f8​: OUTPUT«5␤6␤7␤»
<[Coke]> benabik++
<tadzik> ha, nice
<[Coke]> I was trying to type that out in english. ;)
<tadzik> is that how it should work though?
<tadzik> I mean, is BEGIN necesarry?
<masak> no.
<masak> nom​: sub foo { state $a = 5; say $a++ }; foo; foo; foo
<p6eval> nom 1fd3f8​: OUTPUT«5␤5␤5␤»
<masak> I'm pretty sure that's a bug.
* masak submits rakudobug
<[Coke]> masak​: where in the spec do you see that state $a = 5; should
only be invoked once?
<[Coke]> S04 doesn't seem to imply that.
<benabik> And `BEGIN state` seems to DTRT
<flussence> S04​:1415​: But C<state> automatically applies "start"
semantics to any initializer,
<flussence> but you're right, it doesn't explicitly say BEGIN there...
<PerlJam> also, S03​:4894
<flussence> (imo, it should)
<flussence> oh wait, START does wiw
<masak> what flussence++ said.

@p6rt
Copy link
Author

p6rt commented Oct 24, 2011

From @nwc10

On Mon, Oct 24, 2011 at 01​:04​:18PM -0700, Carl Mäsak wrote​:

<tadzik> nom​: sub foo { state $a = 5; say $a++ }; foo; foo; foo #state NYI?

<flussence> oh wait, START does wiw
<masak> what flussence++ said.

$ perl -E 'sub foo { state $a = 5; say $a++ }; foo; foo; foo'
5
6
7

Perl 5 still ahead here :-)

Nicholas Clark

@p6rt
Copy link
Author

p6rt commented Oct 24, 2011

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

@p6rt
Copy link
Author

p6rt commented Oct 25, 2011

From @jnthn

On Mon Oct 24 14​:04​:00 2011, nicholas wrote​:

On Mon, Oct 24, 2011 at 01​:04​:18PM -0700, Carl Mäsak wrote​:

<tadzik> nom​: sub foo { state $a = 5; say $a++ }; foo; foo; foo
#state NYI?

<flussence> oh wait, START does wiw
<masak> what flussence++ said.

$ perl -E 'sub foo { state $a = 5; say $a++ }; foo; foo; foo'
5
6
7

Perl 5 still ahead here :-)

Can't be having that.

sub foo { state $a = 5; say $a++ }; foo; foo; foo
5
6
7

Unfudged appropriate spectests; resolving ticket.

/jnthn

@p6rt
Copy link
Author

p6rt commented Oct 25, 2011

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

@p6rt p6rt closed this as completed Oct 25, 2011
@p6rt p6rt added the Bug 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