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

C-style for loop does not give an error #637

Closed
p6rt opened this issue Jan 17, 2009 · 10 comments
Closed

C-style for loop does not give an error #637

p6rt opened this issue Jan 17, 2009 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Jan 17, 2009

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

Searchable as RT62478$

@p6rt
Copy link
Author

p6rt commented Jan 17, 2009

From @szabgab

for (my $i = 1; $i <= 3; $i++) { say $i; }

prints 2 instead of giving an intelligent error message that one should use loop
or better yet for 1..3 -> $i { }

Gabor

@p6rt
Copy link
Author

p6rt commented Jan 18, 2009

From @markjreed

On Sat, Jan 17, 2009 at 5​:44 PM, via RT Gabor Szabo
<perl6-bugs-followup@​perl.org> wrote​:

for (my $i = 1; $i <= 3; $i++) { say $i; }

prints 2 instead of giving an intelligent error message that one should use loop
or better yet for 1..3 -> $i { }

A warning, surely? As far as I can tell, the above is perfectly legal
code. Presumably "say $_" would also yield 2, since I gather the for
is looping over ($i).

--
Mark J. Reed <markjreed@​gmail.com>

@p6rt
Copy link
Author

p6rt commented Jan 18, 2009

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

@p6rt
Copy link
Author

p6rt commented Jan 20, 2009

From @moritz

On Sat Jan 17 14​:44​:21 2009, szabgab@​gmail.com wrote​:

for (my $i = 1; $i <= 3; $i++) { say $i; }

prints 2 instead of giving an intelligent error message that one
should use loop
or better yet for 1..3 -> $i { }

Since the for-loop is legal syntax, you should try to bug Larry to make
STD.pm emit a warning, then implementations will follow; since it's not
yet specced, I'll stall this ticket.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jan 20, 2009

@moritz - Status changed from 'open' to 'stalled'

@p6rt
Copy link
Author

p6rt commented Jan 21, 2009

From Andy_Bach@wiwb.uscourts.gov

prints 2 instead of giving an intelligent error message that one should
use loop
or better yet for 1..3 -> $i { }

Presumably "say $_" would also yield 2, since I gather the for
is looping over ($i).

$ perl6 -e ' for (my $i = 1; $i <= 3; $i++) { say $i; }'
2

$ perl6 -e ' for (my $i = 1; $i <= 3; $i++) { say $i; say $_ }'
2
1

So the "++" is applied before the loop body but after the assignment to $_

a


Andy Bach
Systems Mangler
Internet​: andy_bach@​wiwb.uscourts.gov
Voice​: (608) 261-5738; Cell​: (608) 658-1890

History will have to record that the greatest tragedy of this period
of social transition was not the strident clamor of the bad people,
but the appalling silence of the good people.
Martin Luther King, Jr.

@p6rt
Copy link
Author

p6rt commented Jan 21, 2009

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

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

From @coke

On Tue Jan 20 09​:25​:16 2009, moritz wrote​:

On Sat Jan 17 14​:44​:21 2009, szabgab@​gmail.com wrote​:

for (my $i = 1; $i <= 3; $i++) { say $i; }

prints 2 instead of giving an intelligent error message that one
should use loop
or better yet for 1..3 -> $i { }

Since the for-loop is legal syntax, you should try to bug Larry to make
STD.pm emit a warning, then implementations will follow; since it's not
yet specced, I'll stall this ticket.

Cheers,
Moritz

This appears to be resolved​:

21​:10 < coke> std​: for (my $i = 1; $i <= 3; $i++) { say $i; }
21​:10 <+p6eval> std 30000​: OUTPUT<<===SORRY!===NLUnsupported use of C-style
  "for (;;)" loop; in Perl 6 please use "loop (;;)" at
  /tmp/KIPXncZzEo line 1​:NL------> for ?(my $i = 1; $i <= 3;
  $i++) { say $i; }NLFAILED 00​:01 107mNL>>
21​:10 < coke> rakudo​: for (my $i = 1; $i <= 3; $i++) { say $i; }
21​:10 <+p6eval> rakudo aa8c65​: OUTPUT<<Unsupported use of C-style "for (;;)"
  loop; in Perl 6 please use "loop (;;)" at line 11, near "(my $i
  = 1"NLcurrent instr.​: 'perl6;HLL;Grammar;panic' pc 500
  (ext/nqp-rx/src/stage0/HLL-s0.pir​:328)NL>>

Needs tests, though.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Mar 23, 2010

From @moritz

now tested in S04-statements/for.t

@p6rt p6rt closed this as completed Mar 23, 2010
@p6rt
Copy link
Author

p6rt commented Mar 23, 2010

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

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