Can't use function with same name as module?
Shriramana Sharma
not.sure.why.a.mail.id.is.needed.even.if.invalid at gmail.com
Tue Oct 17 06:13:45 UTC 2017
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!
More information about the Digitalmars-d-learn
mailing list