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.

Reply via email to