Function overloading between modules
ketmar
ketmar at ketmar.no-ip.org
Thu Feb 22 21:19:12 UTC 2018
JN wrote:
> Is this expected behaviour?
>
> bar.d
> ---
> void foo(string s)
> {
> }
>
>
> app.d
> ---
>
> import std.stdio;
> import bar;
>
> void foo(int x)
> {
> }
>
> void main()
> {
> foo("hi");
> };
>
>
> ===
> Error: function app.foo (int x) is not callable using argument types
> (string)
yes. this is done so unqualified won't silently "steal" your functions.
this can cause some unexpected (and hard to find) bugs.
if you want it to work, you can either do qualified import
import bar : foo;
or manuall bring overloads from `bar` with
alias foo = bar.foo;
More information about the Digitalmars-d-learn
mailing list