coding practices: include whole module or only the needed function

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 6 23:05:19 PDT 2014


On Mon, 06 Oct 2014 21:24:54 +0000
AsmMan via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
wrote:

> Which practice do you use: if you need only one or two functions 
> from a module:
> 
> import myModule : func, func2;
> 
> or (import whole module, assuming no function name conflits of 
> course)
> 
> import myModule;
> 
> any words why one over the other are welcome.
in C days i was writting something like this:

  #include "something.h"  // i need foo() and bar()

in D such comments can be turned to direct instructions to the
compiler. ;-)

i tend to import "std.stdio" and "std.string" as a whole at the top of
the module (sometimes some other "std." also), and doing local imports
with explicit function enumeration when i need something from other
modules. local imports rocks! ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141007/0a5368bc/attachment.sig>


More information about the Digitalmars-d-learn mailing list