Import concerns revisited
kris
foo at bar.com
Sun Jul 9 16:57:55 PDT 2006
Dave wrote:
> Actually, how about:
>
> import from some.long.modid func as f1, abcd, efgh as zzz;
> private import from this.other.cool.db.lib as dblib;
>
> Is more consistent w/ current syntax, maintains the visual continuity,
> allows more than one symbol import per module (w/o retyping the module),
> and combines the import w/ the alias if desired.
>
> - Dave
Don't wish to belabour the point, but why the private attribute when
it's not really required?
Traditional import:
a - import lib.text.locale;
Safe import:
b - import lib.text.locale as locale;
Selective safe import variations:
1 - import from lib.text.locale Date, Time as myTime;
2 - import lib.text.locale.Date;
import lib.text.locale.Time as myTime;
3 - with lib.text.locale import Date, Time as myTime;
If import consistency is deemed desirable, then #1 & #2 perhaps looks
like the most appropriate in that context? Although the latter seems
notably more verbose. Personally, I like your #1 due to the consistency
of the leading "import"
Whatever the outcome, daily usage should be simple to use and maintain,
obvious, and not tiresomely redundant -- we want to encourage the use of
the safe import.
------------
Contrived illustration:
module lib.net.server.ftp;
import lib.io.file,
lib.text.convert.utf as utf;
import from lib.text.locale Date, Time;
More information about the Digitalmars-d
mailing list