the point of selective importing
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Wed Jul 12 13:24:03 PDT 2006
Rioshin an'Harthen wrote:
> "jcc7" <jcc7_member at pathlink.com> wrote:
>> In article <1wb7225zjf13v.1n8u9dwecz2a8$.dlg at 40tude.net>, Derek Parnell
>> says...
>>> import std.string alias str;
>>> import std.regexp alias re;
>>> import util.str alias utl;
>> I really like that proposed syntax. (We don't /need/ new keywords, so we
>> shouldn't need to add new ones.) I can't believe that syntax would be hard
>> for
>> Walter to add, so it should be added. It would be incredibly useful.
>
> The version I wrote (note that I did not like the distinction between
> 'alias' and 'as', which is why the 'as' was mentioned as optional) with
> selective imports is what I would like to have - not that I'm that likely to
> use selective imports
I guess the libraries are currently written so that there aren't many
name conflicts and thus there's no need to use several namespaces.
> But
> I'm willing to settle for aliased imports (implicitly static, mind), for
> which the approximate grammar would be:
>
> ImportDeclaration:
> 'import' ModuleList ';'
>
> ModuleList:
> ModuleDeclaration
> ModuleDeclaration ',' ModuleList
>
> ModuleDeclaration:
> ModuleName 'alias' AliasedName
> ModuleName
Yes, this is much simpler and perhaps also friendlier to newbies. Yet
another alternative is to use => -symbol and parenthesis:
import modulename => namespacename, module2;
import modulename(member1, member2) => namespacename(foo, bar);
import modulename(member1, member2) => foo, namespacename(bar);
There are really so many possibilities. I would let Walter choose the
syntax he thinks would fit best in D, but let the community decide the
functional requirements. There's a nice summary thread started by Lucas
there. Perhaps we can all find a consensus there.
--
Jari-Matti
More information about the Digitalmars-d
mailing list