Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enh] Issue 12567 - Modules can't be marked as deprecated #3907

Merged
merged 1 commit into from Aug 27, 2014

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Aug 27, 2014

https://issues.dlang.org/show_bug.cgi?id=12567

Points:

  1. Compiler checks the deprecation when the module is imported.

    deprecated("std.regexp is deprecated. Please use std.regex instead.")
    module std.regexp
    module test;
    import std.regexp;  // This line will report the message
  2. ModuleDeclaraion is necessary if you want to make the module deprecated.

  3. Deprecating a module does not deprecate its members automatically.

    It's useful if you want to merely rename modules.

    deprecated("std.regexp is renamed to std.regex.")
    module std.regexp;
    /* All members are not implicitly marked as deprecated */
    module std.regex;
    /* Exactly same contents with in std.regexp. */

@MartinNowak
Copy link
Member

Auto-merge toggled on

@ghost
Copy link

ghost commented Aug 27, 2014

Excellent. However, won't this require a change in the lexer spec? AFAIK the very first thing in a module should either be a shebang or the module declaration, so a deprecated statement should also be added as a possibility.

MartinNowak added a commit that referenced this pull request Aug 27, 2014
[enh] Issue 12567 - Modules can't be marked as deprecated
@MartinNowak MartinNowak merged commit a93bfc1 into dlang:master Aug 27, 2014
@IgorStepanov
Copy link
Contributor

@9rnsr Great enhancement. BTW, do you plan to allow other attributes for module? I tell about language attributes like @safe or @nogs and about UDAs. UDAs for modules and function arguments can significantly extend UDAs programming opportunities.

@9rnsr 9rnsr deleted the fix12567 branch August 28, 2014 01:04
@MartinNowak
Copy link
Member

Excellent. However, won't this require a change in the lexer spec? AFAIK the very first thing in a module should either be a shebang or the module declaration, so a deprecated statement should also be added as a possibility.

What dmd relies on is that the first letter in any source code must be an ASCII character.
This is used to determine the file encoding (UTF-8, UTF16...) and it still works with a deprecated module declaration.

@9rnsr
Copy link
Contributor Author

9rnsr commented Aug 28, 2014

@IgorStepanov I opened documentation fix: dlang/dlang.org#642

@yebblies
Copy link
Member

Hmm ok.

  1. The error message is not suppressed when one deprecated module imports another.
  2. Import statements don't give an error.
  3. Imports inside deprecated declarations don't suppress the error.

@IgorStepanov
Copy link
Contributor

@9rnsr I asked about UDAs for modules like

@BindModule("foobar") @safe module foo.bar;
...
pragma(msg, __traits(getAttributes, foo.bar));

... and about function parameter attributes:

void foo(@BindParam("A") int a, @BindParam("B") int b){}
...
pragma(msg, __traits(getArgumentAttributes, foo, 0)); //a attributes
pragma(msg, __traits(getArgumentAttributes, foo, 1)); //b attributes

@9rnsr
Copy link
Contributor Author

9rnsr commented Aug 29, 2014

@IgorStepanov If you want to request new language feature, please file it in bugzilla with reasonable use cases.

@MartinNowak MartinNowak added this to the 2.066.1 milestone Oct 8, 2014
MartinNowak added a commit to MartinNowak/dmd that referenced this pull request Oct 8, 2014
[enh] Issue 12567 - Modules can't be marked as deprecated
Conflicts:
	src/hdrgen.c
	src/module.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants