Import concerns revisited

Regan Heath regan at netwin.co.nz
Tue Jul 11 17:38:47 PDT 2006


On Tue, 11 Jul 2006 23:47:27 +0000 (UTC), Bill Baxter  
<Bill_member at pathlink.com> wrote:
> Q1: How many D users out there are *opposed* to imports being private by
> default?  Even if it requires everyone to change their code?

+1 .. but I don't have a large body of code to 'fix'

> Q2: How many D users out there are *opposed* to imports being "static" by
> default?  Even if it requires fixing the imports in every D source file
> everywhere?

By "static" do you mean:

import std.stdio;
writefln("Hello World");           //error
std.stdio.writefln("Hello World"); //ok

If so, -1, I don't like this. I like D's import into 2ndary namespace and  
lookup mechanism as a default. I dont like using FQN unless I have to, to  
disambiguate, and even then I'd prefer the 'as' solution to import into a  
shorter namespace.

There seems to me to only be a minor difference in functionality between..

import std.stdio;
alias std.stdio io;

writefln("");    //ok
io.writefln(""); //ok

and..

import std.stdio as io;

writefln("");    //error
io.writefln(""); //ok

in that the latter syntax allows the compiler to _not_ import into the  
2ndary namespace and _instead_ into the named one, instead of doing both,  
which is what appears does/will happen using 'alias'. I prefer this.

Regan



More information about the Digitalmars-d mailing list