What is the reasoning behind the lack of conversions when passing parameters

Basile B. b2.temp at gmx.com
Mon Feb 5 19:16:40 UTC 2024


On Saturday, 3 February 2024 at 18:53:02 UTC, Carl Sturtivant 
wrote:
> On Saturday, 3 February 2024 at 17:58:22 UTC, Walter Bright 
> wrote:
>> P.S. Overloading is often used excessively, even in the DMD 
>> source code.
>
> I wonder why overloading doesn't need an `overload` keyword at 
> the site of an overloaded function definition.

What D does is "implicit" overload creation. If the same name 
already exists in the current scope it just creates an "overload 
set", adding possible candidates in a sort of linked list. There 
are restrictions however on what can be part of a set, for 
example you cannot overload a function declaration with an int 
declaration.

However this becomes complicated when it's about eponymous 
templates. There are probably still a couple of bugs related to 
that, because the way the semantics of a D program are checked 
does not allow to verify 100% of the time that the eponymous 
member(s) (yes plural) are all functions.


More information about the Digitalmars-d mailing list