Best practice and module declarations

Philippe Sigaud philippe.sigaud at gmail.com
Thu Jul 15 00:57:15 PDT 2010


I was wondering what the general consesus was (if there is one) on whether
>> it's
>> valuable to always put module declarations in each module.
>>
>

> I can't think of any particularly strong reasons to have it or not to have
>> it.
>> My first reaction is to just always use it, but thinking about it, I'm not
>> sure
>> that there's really much point if the file name and the module name
>> already
>> match. Does anyone have reasons why it would matter other than personal
>> preference?
>>
>
>
I can see two reasons to use module declarations:

- you can put documentation comments before the module declaration, to have
them at the beginning of the docs. That's where you put general indications
on the use of this module, and copyright/author/license indications. I quite
like these module-level docs, personally.

- it defines a new symbol, which you can use in template with alias
parameters and __traits, like in __traits(allMembers, moduleName). If you're
into compile-time introspection, that can be useful.
(though maybe these symobols exist even without module decls, I don't know).


Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100715/6130e35e/attachment.html>


More information about the Digitalmars-d-learn mailing list