Skip to content

Commit

Permalink
Merge pull request #1229 from Geod24/deprecated-assignexp-pr5302-issu…
Browse files Browse the repository at this point in the history
…e12954

[2.071.0] Document deprecated attribute as accepting AssignExp
  • Loading branch information
schuetzm committed Feb 12, 2016
2 parents c8fc79c + 95d57ac commit ffdb17c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions spec/attribute.dd
Expand Up @@ -289,7 +289,7 @@ $(H3 $(LNAME2 deprecated, $(D deprecated) Attribute))
$(GRAMMAR
$(GNAME DeprecatedAttribute):
$(D deprecated)
$(D deprecated $(LPAREN)) $(GLINK2 lex, StringLiteral) $(D $(RPAREN))
$(D deprecated $(LPAREN)) $(GLINK2 expression, AssignExpression) $(D $(RPAREN))
)

$(P It is often necessary to deprecate a feature in a library,
Expand All @@ -308,15 +308,27 @@ $(GNAME DeprecatedAttribute):
oldFoo(); // Deprecated: function test.oldFoo is deprecated
---------------

$(P Optional $(GLINK2 lex, StringLiteral) can show additional
information in the deprecation message.
$(P Optionally a string literal or manifest constant can be used
to provide additional information in the deprecation message.
)

---------------
deprecated("Don't use bar") void oldBar();
oldBar(); // Deprecated: function test.oldBar is deprecated - Don't use bar
---------------

$(P Calling CTFE-able functions or using manifest constants is also possible.
)

---------------
import std.format;
enum Message = format("%s and all its members are obsolete", Foobar.stringof);
deprecated(Message) class Foobar {}
auto f = new Foobar(); // Deprecated: class test.Foobar is deprecated - Foobar and all its members are obsolete
deprecated(format("%s is also obsolete", "This class")) class BarFoo {}
auto bf = new BarFoo(); // Deprecated: class test.BarFoo is deprecated - This class is also obsolete
---------------

$(P $(D Implementation Note:) The compiler should have a switch
specifying if $(D deprecated) should be ignored, cause a warning, or cause an error during compilation.
)
Expand Down Expand Up @@ -818,4 +830,3 @@ pragma(msg, __traits(getAttributes, typeof(a))); // prints tuple("hello")
Macros:
TITLE=Attributes
WIKI=Attribute

2 changes: 1 addition & 1 deletion spec/grammar.dd
Expand Up @@ -1637,7 +1637,7 @@ $(GNAME AlignAttribute):
$(GRAMMAR
$(GNAME DeprecatedAttribute):
$(D deprecated)
$(D deprecated $(LPAREN)) $(GLINK_LEX StringLiteral) $(D $(RPAREN))
$(D deprecated $(LPAREN)) $(GLINK2 expression, AssignExpression) $(D $(RPAREN))
)

$(GRAMMAR
Expand Down

0 comments on commit ffdb17c

Please sign in to comment.