digitalmars.D - Function with same name as a module name
- Daniel Kozak (10/10) Nov 29 2014 module main;
- Xinok (7/17) Nov 29 2014 It's a little confusing but it is referring to module main and
- Daniel Kozak (2/21) Dec 01 2014 No, it is refer to main function. And try to call UFCS a(main);
- Jeremy DeHaan (5/5) Dec 01 2014 I don't think you can specify look ups with the name of the
- Daniel Kozak via Digitalmars-d (4/8) Dec 01 2014 You can. It doesn't work only when there is a another symbol with same
- Jeremy DeHaan (7/17) Dec 01 2014 I don't see it mentioned at all in this:
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 ()
Nov 29 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. :-/
Nov 29 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:No, it is refer to main function. And try to call UFCS a(main);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.
Dec 01 2014
I don't think you can specify look ups with the name of the module in the same module like you can with imported ones. If you want to specify that it is a variable in module scope, use the module scope operator. writeln(.a); // the leading '.' specifies module scope
Dec 01 2014
Dne Mon, 01 Dec 2014 18:10:35 +0100 Jeremy DeHaan via Digitalmars-d <digitalmars-d puremagic.com> napsal(a):I don't think you can specify look ups with the name of the module in the same module like you can with imported ones. If you want to specify that it is a variable in module scope, use the module scope operator. writeln(.a); // the leading '.' specifies module scopeYou can. It doesn't work only when there is a another symbol with same name as a module. But it makes a sense.
Dec 01 2014
On Monday, 1 December 2014 at 20:29:48 UTC, Daniel Kozak via Digitalmars-d wrote:Dne Mon, 01 Dec 2014 18:10:35 +0100 Jeremy DeHaan via Digitalmars-d <digitalmars-d puremagic.com> napsal(a):I don't see it mentioned at all in this: http://dlang.org/module.html It sounds like something was over looked. Either you shouldn't be able to specify with the module name in the same module, or you shouldn't be getting this error.I don't think you can specify look ups with the name of the module in the same module like you can with imported ones. If you want to specify that it is a variable in module scope, use the module scope operator. writeln(.a); // the leading '.' specifies module scopeYou can. It doesn't work only when there is a another symbol with same name as a module. But it makes a sense.
Dec 01 2014