I suggest we ...

Add possibility to use break and continue in f# loops. And do while loop

It very often looks better than recursion, and it would be wonderful to have this possibility

12 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Vladimir shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    6 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Vladimir commented  ·   ·  Flag as inappropriate

        Sequences is very slow and there are some situation when performance is required. For example when you work with matrices. Also you can't always use Array module, because its functions always copy array, that is not very well in most cases. So if you can said, how to work with it without recursion, I will be very glad.
        I see very often, when some one use "rec loop" for making loops functionality. I think it's awful.
        I think if you don't need loops (with break and continue) you can don't to use it. I think it's not a big problem to implement this feature and you can decide for yourself, should you use it or not.

      • Richard Gibson commented  ·   ·  Flag as inappropriate

        I'm also not convinced this is a good idea - most of the time when I was learning F# and I wished for break or continue it was because I didn't know how to use the appropriate F# sequence function yet. `Pick` and `find` are two functions that come to mind in helping get out of the imperative way of thinking.

        If you have any examples on where it's truly necessary or preferable to use break / continue I'd love to see them, only because I can't think of any myself.

      • Vladimir commented  ·   ·  Flag as inappropriate

        but when we working with arrays, it's not so clear to use recursion. Especially, when we must modify the array. In this case recursion looks very ugly, especially, we must send a lot of arguments there.
        P.S. I also like functional style, but in some cases imperative style is much better. And it's very sad when I cant use the best way to resolve some problem in my favorite language, and should use for that, for example, c#

      • Phylos commented  ·   ·  Flag as inappropriate

        I don't think this is a good idea, as it would encourage perpetuating imperative programming approaches to those new to F#.

      • Richard Minerich commented  ·   ·  Flag as inappropriate

        I have mixed feelings about this. On one hand there have been cases where having this would be useful for porting code from other languages, on the other I'd be worried that many would start to use these in cases that are more clearly expressed as recursion and in so doing make the code much more difficult to understand and maintain.

      F# Language

      Feedback and Knowledge Base