Function with same name as a module name

Daniel Kozak via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 1 03:59:47 PST 2014


On Saturday, 29 November 2014 at 22:25:46 UTC, Xinok wrote:
> 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.

No, it is refer to main function. And try to call UFCS a(main);



More information about the Digitalmars-d mailing list