Hello.

fun.d:
import std.stdio;
void fun() { writeln("Hello"); }

main.d:
import fun;
void main() { fun(); }

$ dmd -oftest fun.d main.d
main.d(2): Error: function expected before (), not module fun of type void

Why can't I use a function of the same name as the module? IIUC import fun imports all the top-level symbols within module fun as well as the symbol fun referring to the module itself. This is just another case of overloading, no? Can't the compiler understand that I am trying to call the function fun.fun() and not the module even when it is followed by ()?

Thanks!

Reply via email to