Clay language

spir denis.spir at gmail.com
Wed Dec 29 05:30:23 PST 2010


On Tue, 28 Dec 2010 18:37:37 +0100
Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:

> On 12/28/10, Adam Ruppe <destructionator at gmail.com> wrote:
> > That's not the only bad part. It also means refactoring your modules
> > requires changes to the user code too. See my other post here:
> 
> Actually, D is equipped to solve even that problem. If you really want
> to use fully qualified names and reserve the right to rename a module,
> you can do this:
> 
> foo.d:
> import std.stdio : writeln;
> void bar()
> {
>     writeln("bar");
> }
> 
> main.d:
> static import foo = foo;
> void main()
> {
>     foo.bar();
> }
> 
> If you decide to rename the foo module to "foobar", all you need to
> change is one line in main:
> static import foo = foobar;
> 
> This is much saner than bearophile's "force full qualified names by
> default", since it still allows you to refactor your modules with the
> minimum amount of changes in the importing code.

Waow! had not guessed that. Thanks for the tip :-) But it does not change anything relating to the 'feature' "import every symbol by default", as far as I can tell. Or what? On the contrary, it seems to me this helps & having good documentation practice and/or clearer code without potential refactoring issues. (Which anyway find&replace "foo." --> "foobar." solves is 99% cases.)

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list