Accessing class with module name as Java's
tcak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 12 09:31:39 PST 2015
In java, if I create a file, the class that is defined in it must
have the same name of file. So, with the file name, I can relate
to class directly. Is there any way to achieve this in D?
One way I achieved it, though I cannot put namespace on it.
file: project.d
==================
module project;
class project{}
file: main.d
==================
import project: project;
auto p = new project();
When I do this, it works, but I cannot make it work with
namespace unfortunately.
Any simple (complexity isn't desired please) way to do this?
My only though without breaking anything in the language is to
relate a struct or class to module itself to do this, but it
might require a new keyword.
More information about the Digitalmars-d-learn
mailing list