Naming issue importing different function overloads
data pulverizer
data.pulverizer at gmail.com
Mon May 31 17:08:28 UTC 2021
On Sunday, 30 May 2021 at 18:50:25 UTC, Adam D. Ruppe wrote:
> On Sunday, 30 May 2021 at 18:42:34 UTC, data pulverizer wrote:
>> I wonder if it is a purposeful design
>
> It is by design: https://dlang.org/articles/hijack.html
>
> Basically the idea behind it is to make sure that a change in a
> lib you import doesn't change your existing code without you
> realizing it.
>
> You can merge them at the import site by doing
>
> import funs;
>
> doubme myfun(...) {}
>
> alias myfun = funs.myfun; // this line merges them
>
>
> You can also use a selective import to merge them:
>
>
> import funs : myfun;
> double myfun(...) {}
>
>
> now both myfuns work.
>
>
> this works because the `import x : y;` is actually shorthand
> for a local alias.
Many thanks
More information about the Digitalmars-d-learn
mailing list