avoid member overloads
See original GitHub issueIt would be nice to avoid overloads. While working on http://blog.ctaggart.com/2017/11/how-to-create-http2-app-in-f.html, it was a major pain to get the F# compiler to use the correct unique overload, especially with optional parameters and base classes that have identical signatures.
That is from server.listen 8843.
.
I had issues withe end
as well:
type [<AllowNullLiteral>] ServerHttp2Stream =
inherit Http2Stream
type [<AllowNullLiteral>] Http2Stream =
inherit stream.Duplex
abstract ``end``: unit -> unit
abstract ``end``: chunk: obj * ?cb: Function -> unit
abstract ``end``: chunk: obj * ?encoding: string * ?cb: Function -> unit
type [<AllowNullLiteral>] stream.Writable =
abstract ``end``: unit -> unit
abstract ``end``: chunk: obj * ?cb: Function -> unit
abstract ``end``: chunk: obj * ?encoding: string * ?cb: Function -> unit
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to prevent Overloading? - c++
Member function declarations with the same name and the same parameter types cannot be overloaded if any of them is a static member...
Read more >Functions that cannot be overloaded in C++
In C++, following function declarations cannot be overloaded. 1) Function declarations that differ only in the return type.
Read more >Member Overloading - Framework Design Guidelines
In this article. Member overloading means creating two or more members on the same type that differ only in the number or type...
Read more >I don't understand the arguments against operator ...
In general, I avoid using operator overloading in non-intuitive ways. That is, if I have a numeric class, overloading * is acceptable (and ......
Read more >Controlling overload resolution #1: Preventing implicit ...
Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As a counterpoint to this issue, I think method overloads are doable if we avoid
obj
type and had return types that were tied to specific options. See here for more infoYes, overloads are complicated in F#, that was one of the reasons to create the erased unions instead of automatically generating overloads.
I cannot think of a solution now. If adding a suffix I would like something more meaningful than just the number of parameters, but I know this is hard to with an automatic processor. @jgrund is right in that filling some
obj
s would help the compiler. I’ve also seen sometimes that removing optional arguments solves the ambiguity (see this commit), maybe we could try to implement an algorithm to see when can this be done.