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

Rakudo doesn't DTRT with 'state' variables and cloned blocks #607

Closed
p6rt opened this issue Jan 11, 2009 · 5 comments
Closed

Rakudo doesn't DTRT with 'state' variables and cloned blocks #607

p6rt opened this issue Jan 11, 2009 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jan 11, 2009

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

Searchable as RT62184$

@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

From @masak

Rakudo r35404 doesn't work according to spec in the area of 'state'
variables and cloned blocks.

$ perl6 -e 'my $i = 0; my $func = { state $x = $i++; say $x }; my ($a,
$b) = $func.clone, $func.clone; $a(); $b(); $a()'
0
1
2

According to S04, this should be equivalent to

$func = { state $x will start { $x = $i++ }; say $i };

and thus (in my understanding) produce

0
1
1

@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

From @masak

Carl (>)​:

Rakudo r35404 doesn't work according to spec in the area of 'state'
variables and cloned blocks.

$ perl6 -e 'my $i = 0; my $func = { state $x = $i++; say $x }; my ($a,
$b) = $func.clone, $func.clone; $a(); $b(); $a()'
0
1
2

According to S04, this should be equivalent to

$func = { state $x will start { $x = $i++ }; say $i };

Arrgh, that should be 'say $x', of course.

and thus (in my understanding) produce

0
1
1

@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Mar 17, 2009

From @jnthn

On Sun Jan 11 04​:59​:51 2009, masak wrote​:

Rakudo r35404 doesn't work according to spec in the area of 'state'
variables and cloned blocks.

$ perl6 -e 'my $i = 0; my $func = { state $x = $i++; say $x }; my ($a,
$b) = $func.clone, $func.clone; $a(); $b(); $a()'
0
1
2

According to S04, this should be equivalent to

$func = { state $x will start { $x = $i++ }; say $i };

and thus (in my understanding) produce

0
1
1

Actually expected output is​:

0
1
0

Or at least I talked at least two other people into #perl6 into agreeing
with me that it should be. ;-)

Added this with 0/1/0 as expected output to the spectests, and it's passing.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Mar 17, 2009

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

@p6rt p6rt closed this as completed Mar 17, 2009
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