Remove warning for new keyword on IDisposable
The only time I ever use the new keyword is on Disposables, and even then only to silence the compiler warnings. I'm not sure what purpose the warning serves either, because you can still forget to bind the disposable with the use keyword instead of with let. What's more annoying is that it prevents you from effective pipelining.
Could this be removed from the next F# release, or perhaps replaced with a warning if you bind a Disposable with let instead of use?

6 comments
-
miegir commented
I agree that this warning can be removed and replaced by the warning that IDisposable object should be either bound using 'use' or returned. And that warning should also be reported on methods that return IDisposable values. And, for completeness, using of the 'new' keyword will suppress that new warning, allowing developer to say 'I know that I do here'.
-
Jared Hester commented
I also find this warning very useful and it definitely should not be removed. Reed's alternative is a much more useful approach.
If you forget to bind to `use` with the `new` right there, that's on you ;P
If the real issue is with how it currently can't be pipelined, why not ask for just that instead?
-
Reed Copsey, Jr. commented
-
Gauthier Segay commented
I agree with Reed and use same convention, and I do benefit from the warning.
To workaround the fact you can't use the constructor as first class function only takes a single line function while having the warning and convention of using new only for IDisposable could form a nice convention in F# codebases.
-
Reed Copsey, Jr. commented
Binding a disposable with let is a common requirement if you're authoring libraries.
I find the current warning _very_ valuable. If you never use "new", the warning effectively tells you whenever you allocate something that's disposable, and also provides a simple way in your code to see all uses of disposable.
-
Alexei Odeychuk commented
I support Isaac Abraham's suggestion!