www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Deprecating a module

reply "Jon Giddy" <jongiddy gmail.com> writes:
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/
ource/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.
Apr 23 2014
next sibling parent Andrej Mitrovic via Digitalmars-d <digitalmars-d puremagic.com> writes:
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() { } -----
Apr 24 2014
prev sibling next sibling parent Andrej Mitrovic via Digitalmars-d <digitalmars-d puremagic.com> writes:
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!
Apr 24 2014
prev sibling parent "Dicebot" <public dicebot.lv> writes:
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.
Apr 24 2014