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

Improved loop operations #8016

Closed
vicuna opened this issue Feb 14, 2003 · 1 comment
Closed

Improved loop operations #8016

vicuna opened this issue Feb 14, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Feb 14, 2003

Original bug ID: 1544
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Daniel M. Albro
Version: 3.0.6
OS: Linux and Windows
Submission from: vp191002.reshsg.uci.edu (128.195.191.2)

I am wondering if there is some way to improve the
imperative loop operations slightly, to give programmers
better control over areas of their code that have to
run fast... The following would be nice:

  1. step values for for loops. Example:

    for i = 0 to 9 by 2 do
    Printf.printf "%d " i
    done

    0 2 4 6 8

  2. break statements ("exit loop", or whatever). I realize that break can be
    simulated by using reference variables to control while loops
    and setting the variable such that the toplevel test will fail,
    but this is not an appealing way to program. I also realize that
    break can be simulated by exception throwing, but I've noticed this
    is slow compared to the first simulation method.

@vicuna
Copy link
Author

vicuna commented Apr 18, 2004

Comment author: administrator

Better use tail recursion in both cases. I'd rather keep loops as basic as
possible. XL, 2004-04-18

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