Fsharp: Many 'do's allowed

Created on 19 Nov 2019  路  4Comments  路  Source: dotnet/fsharp

let c =
    let mutable c = 0
    fun () ->
        do do do do do do do do do do do do do do c <- c + 1
        c

The following silly code will compile and run as you'd expect it to. I'm not sure it's a bug, but it certainly is an oddity.

Most helpful comment

Don't take away my new toy @cartermp :P

All 4 comments

Don't take away my new toy @cartermp :P

Hilarious! Never thought of it, but it makes sense. do expects unit and returns unit. If anything, it should be by design.

I think this should be closed as by design. It's similar to other languages where you can create as many nested blocks as you want.

@forki Not quite. I bet there's a limit before the F# compiler crashes 馃檪

Was this page helpful?
0 / 5 - 0 ratings