question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

avoid member overloads

See original GitHub issue

It 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.

image

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:open
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jgrundcommented, Nov 22, 2017

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 info

0reactions
alfonsogarciacarocommented, Nov 23, 2017

Yes, 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 objs 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found