Function with same name as a module name

Xinok via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 29 14:25:45 PST 2014


On Saturday, 29 November 2014 at 19:35:52 UTC, Daniel Kozak wrote:
> module main;
> import std.stdio;
>
> struct A {}
>
> static A a;
>
> void main() {
> 	writeln(main.a);
> }
>
> this code does not work, because it try to use main function 
> instead of main module. Even error message is wierd: Error: 
> struct A does not overload ()

It's a little confusing but it is referring to module main and 
not the function main. I think the error message is because 
struct A doesn't define opCall. See:

http://dlang.org/operatoroverloading.html#function-call

I tried to provide an example, but I couldn't get the code to 
compile myself. :-/


More information about the Digitalmars-d mailing list