Hi all,
On Mon, Nov 16, 2009 at 12:01 AM, Ian Lance Taylor <
ia...@google.com> wrote:
> In Go
> import . "package"
> is mainly intended for testing. It makes it easier to move testing
> code in and out of the package as desired. No doubt some people will
> misuse it, but we hope not many.
So you have a module foo. You initially write test code in foo, but
later decide you want to move it to foo-test instead. So foo-test now
imports foo with the dot and therefore you don't have to change the
testing code in the course of moving it. Correct?
What about doing it the other way around: Instead of *breaking* the
encapsulation of foo so that foo-test doesn't have to change, make foo
*allow* foo-test to "embed" itself into foo. Inside of foo you'd have
something like this (borrowing a keyword from C++):
import "bla";
import "lalala";
friend "foo-test"; // allow foo-test to embed without qualifying
Inside of foo-test you'd have this:
import . "foo"; // embed into foo
The meaning of "dotted" import is changed to "Only if the exporting
module allows dotted import to the importing module." Note that I
couldn't care less for "friend," replace that with whatever you want,
maybe another special import clause:
import > "foo-test";
The point is that the existing mechanism breaks modularity in
arbitrary ways. This one would only break it in very limited ways to
allow exactly your example. And it's controlled by the exporting
module, not the importing one.
Disclaimer: This idea may be severely broken in arbitrary ways. :-/