asynchronousf#dispose

Does _ (discard) not make sense for use! bindings?


It seems to me that there is an asymmetry here:

// Ok
use _ = { new IDisposable with member _.Dispose() = printfn "disposed" }

// Error! FS1288
use! _ = Async.OnCancel (fun () -> printfn "disposed")

How come there is this constraint imposed on the second use binding? Is it simply a case of "not spec'd and implemented yet" or is there a deeper reason?

Neither googling, nor binging FS1288 gave any helpful result.


Solution

  • Allowing underscore in use bindings is a fairly recent addition to the language. There was apparently no discussion at the time of allowing it for use! bindings as well. Perhaps no one thought of it, and you could add it as a suggestion.