On Tue, Nov 15, 2016 at 11:14 AM Dominic Grostate < codekest...@googlemail.com> wrote:
> I think this may have been discussed before, but I was largely dismissed > because no one though it would be possible to implement. > > However assuming it is possible, what is the general feeling towards > function overloading, as seen in C# and Java? > > To me, it saves me coming up with convoluted names for tackle various > parameter combinations, even though the function/methods themselves all do > the same thing, as well as saving having to omit type hinting in order to > manually type check within the function. > > The previous RFC on union types attempted to fulfill a similar operation, > but it failed to go through, but given the support it never the less had, > I'm hoping that overloading will be more acceptable. > > To give an idea of how I'd implement it, I'd first try by hashing the > function name with the type hints, plus the number of arguments, with > variadics and references also taken into account on top of handling of > dynamic arguments. > > The exact method is open to implementation, but it is possible to create an > order priority and conflict resolution to enable overloading, while > hopefully maintaining backwards compatibility with all existing > core/ext/user functions. > > Please give your thoughts, thanks, > Dominic > Without scalars alone this just becomes a headache to debug. Which function will be called if the scalar matches none of the function signatures? It's really to easy to change a variable's type. Casting can help, but it's still touchy.