Thread overview
Deprecating a module
Apr 24, 2014
Jon Giddy
Apr 24, 2014
Andrej Mitrovic
Apr 24, 2014
Andrej Mitrovic
Apr 24, 2014
Dicebot
April 24, 2014
Is there a good way to deprecate a module?  The deprecated attribute only applies to declarations, so doesn't appear to work for the module header.

As a particular example, to solve problems with mismatched module names and pathnames, I moved some files to new locations.  To support anyone who was still using the old module name, I created a file in the location of the old module name (see https://github.com/pszturmaj/ddb/blob/c285cad465b23fba59a30f6cdfd76e8ad760a65f/source/postgres/db.d ).

The file uses a static module constructor to display a run-time warning. Since the file simply imports the new module, there isn't anywhere to hang a deprecated attribute, to trigger a compile-time warning/error.
April 24, 2014
On 4/24/14, Jon Giddy via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> Is there a good way to deprecate a module?

It's a filed enhancement: https://issues.dlang.org/show_bug.cgi?id=12567

As a current workaround you can use a deprecated block:

-----
module bar;

deprecated:

void test() { }
void test2() { }
-----
April 24, 2014
On 4/24/14, Jon Giddy via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> Is there a good way to deprecate a module?

Also, please ask these types of questions in D.learn in the future. Thanks!
April 24, 2014
On Thursday, 24 April 2014 at 06:13:31 UTC, Jon Giddy wrote:
> The file uses a static module constructor to display a run-time warning. Since the file simply imports the new module, there isn't anywhere to hang a deprecated attribute, to trigger a compile-time warning/error.

I don't know of a single way to do true deprecation (controllable by -w* switches) but you can emulate it by placing module-global static assert or pragma(msg).

We could make this work without changing the language by respecting `deprecated static this() {}` in such module by the way.