loop over range should use 'int' variable if endpoints are 'small'
See original GitHub issueGiven:
for (i in 0:10) { ... }
for (i in 1..10) { ... }
Or:
small Integer x = 0;
small Integer y = 10;
for (i in x:y) { ... }
for (i in x..y) { ... }
The compiler should use an int
for the loop variable i
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
How to iterate through range based for loop with variable end ...
Range -based for loop is pure sugar - it can only iterate over the entire range. If you need to play with the...
Read more >For loop with range - Learn Python 3 - Snakify
Another use case for a for-loop is to iterate some integer variable in ... Such a sequence of integer can be created using...
Read more >C Programming Course Notes - Looping Constructs
The correct loop should use an integer counter to complete the loop a given number of times, and use the low end of...
Read more >Python Range function - How to Use Python Range()
A range is a close interval between two points. This tutorial explains what is Python Range function and how to use it in...
Read more >Range-based for loop (since C++11) - cppreference.com
Each element of the sequence, in turn, is dereferenced and is used to initialize the variable with the type and name given in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That would be fine by me.
@xkr47 FTR JVM microbenchmarks have shown that a java for loop over an
int
is much faster than the same loop using along
. So this would be a worthwhile optimization to have.