Proposal for an extension to the import syntax
Bill Baxter
dnewsgroup at billbaxter.com
Mon Dec 11 19:20:04 PST 2006
Chris Nicholson-Sauls wrote:
> Trevor Parscal wrote:
>> Why not just use
>>
>> import package.*;
>>
>> it makes sense in regexp statements, it works for java, why not use it
>> here?
>> What's the problem?
>
> Problems:
I agree that * is not so hot. I don't know about in Java circles, but
at least in the Python world using "import foo.*" is generally frowned
upon for anything other than use at the interactive prompt to save some
typing.
But there is a real need, I think, for a more compact syntax for
importing several modules deep down in a package hierarchy.
import somebodys.long.package.name.module1;
import somebodys.long.package.name.module2;
import somebodys.long.package.name.module3;
just doesn't look so slick. This is exactly the same issue that got
debated endlessly regarding individual symbols, which resulted
eventually in the syntax
import somebodys.long.package.name.module1 : sym1,sym2,sym3;
except now we're talking about it at the module level rather than the
symbol level.
Personally, I think the solution should be to allow things like:
import somebodys.long.package.name : module1, module2, module3;
and maybe also
import somebodys.long.package.name : module1.sym1, module2.sym2;
maybe even
import somebodys.long.package.name : (module1:sym1), (module2:sym2);
But I think at least the first one should work.
--bb
More information about the Digitalmars-d
mailing list