Accessing class with module name as Java's
Daniel Kozák via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 13 03:53:49 PST 2015
V Tue, 13 Jan 2015 10:58:27 +0000
tcak via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
napsáno:
> >
> > Ah, I just re-read your OP. Your already at this point :)
>
> Since everybody has understood the problem, and nobody could have
> come up with a solution yet, my idea is that:
>
> HttpSocketConnectionRequest.d
> =====================================
> module net.http.HttpSocketConnectionRequest;
>
> module class HttpSocketConnectionRequest{}
>
>
> If compiler allowed "module" keyword to be used as an attribute
> for ONLY ONE class or struct definition in the module as above,
> module's name could be used as you were to be pointing to class
> directly.
>
> This would let us (and Phobos developers) to be able to separate
> code files into multiple files much easily, and solve my problem
> as well :).
There is a way around:
-- main.d --
import std.stdio;
import net.http;
void main(string[] arg)
{
auto p = new net.http.HttpSocketConnectionRequest();
}
-- net/http/package.d --
module net.http;
private import net.http.http_socket_connection_request;
-- net/http/http_socket_connection_request.d --
module net.http.http_socket_connection_request;
class HttpSocketConnectionRequest {
}
or
-- main.d --
import std.stdio;
static import net.http;
void main(string[] arg)
{
auto p = new net.http.HttpSocketConnectionRequest();
}
-- net/http/package.d --
module net.http;
import net.http.http_socket_connection_request;
-- net/http/http_socket_connection_request.d --
module net.http.http_socket_connection_request;
class HttpSocketConnectionRequest {
}
More information about the Digitalmars-d-learn
mailing list