Allow "deprecated" to accept more than string literals while parsing

Brian Schott via Digitalmars-d digitalmars-d at puremagic.com
Sun May 31 20:33:48 PDT 2015


Here's something that I ran into while writing dfix`s implicit 
string concatenation cleanup code:

```
// accepted
deprecated("This function is dumb and you shouldn't use it)
void deleteT3hH4rdDisk();

// accepted
deprecated("This function is dumb and" " you shouldn't use it)
void deleteT3hH4rdDisk();

// parse error
deprecated("This function is dumb and" ~ " you shouldn't use it)
void deleteT3hH4rdDisk();
```

According to this[1] the behavior is correct, however it is not 
intuitive that a programmer cannot split up the string for 
"deprecated" over multiple lines without depending on D's 
bug-prone behavior of implicitly joining adjacent string literals.

There are two solutions to this that I see, one is to allow a 
combination of string literals and "~" operators, and the other 
is to allow arbitrary expressions that evaluate to a string.

Right now I favor allowing string literals and "~" because it's a 
smaller change. I can write up a DIP for this if there's a decent 
chance of this getting approved.

[1] http://dlang.org/grammar.html#DeprecatedAttribute


More information about the Digitalmars-d mailing list