digitalmars.D - New thing I learned for the day
- Steven Schveighoffer (9/9) Nov 26 2019 Did you know this was valid syntax? I didn't.
- Adam D. Ruppe (5/6) Nov 26 2019 I did not know already, but it is no surprise to me either
- Steven Schveighoffer (8/14) Nov 26 2019 static if and version are not attributes. But actually, I didn't know
- Timon Gehr (4/21) Nov 26 2019 static foreach(i;0..10):
- H. S. Teoh (7/11) Nov 28 2019 Ouch. That's ... ouch.
Did you know this was valid syntax? I didn't. static if(cond) ... else: // wat... seen here: https://github.com/dlang/phobos/blob/3bfccf4f160a07165682549407eaeec5c8907c82/std/utf.d#L4213-L4215 Only seems to work outside of functions, and naturally then not for normal if statements. -Steve
Nov 26 2019
On Tuesday, 26 November 2019 at 15:28:38 UTC, Steven Schveighoffer wrote:Did you know this was valid syntax? I didn't.I did not know already, but it is no surprise to me either because the colon works on almost every other attribute like that too... static if and version are similar according to teh grammar.
Nov 26 2019
On 11/26/19 10:35 AM, Adam D. Ruppe wrote:On Tuesday, 26 November 2019 at 15:28:38 UTC, Steven Schveighoffer wrote:static if and version are not attributes. But actually, I didn't know that it works with version as well. Seems to also work with a debug condition according to grammar. What's weird is that it doesn't work in a function, but I guess those are considered a different part of the grammar. In any case, I probably will not be using it. But I did a double take when I saw it... -SteveDid you know this was valid syntax? I didn't.I did not know already, but it is no surprise to me either because the colon works on almost every other attribute like that too... static if and version are similar according to teh grammar.
Nov 26 2019
On 26.11.19 16:50, Steven Schveighoffer wrote:On 11/26/19 10:35 AM, Adam D. Ruppe wrote:static foreach(i;0..10): pragma(msg, ":P"); pragma(msg, "!");On Tuesday, 26 November 2019 at 15:28:38 UTC, Steven Schveighoffer wrote:static if and version are not attributes. But actually, I didn't know that it works with version as well. Seems to also work with a debug condition according to grammar. What's weird is that it doesn't work in a function, but I guess those are considered a different part of the grammar. In any case, I probably will not be using it. But I did a double take when I saw it... -SteveDid you know this was valid syntax? I didn't.I did not know already, but it is no surprise to me either because the colon works on almost every other attribute like that too... static if and version are similar according to teh grammar.
Nov 26 2019
On Tue, Nov 26, 2019 at 05:02:26PM +0100, Timon Gehr via Digitalmars-d wrote: [...]static foreach(i;0..10): pragma(msg, ":P"); pragma(msg, "!");Ouch. That's ... ouch. Chalking this down to one of the darker corners of D. :-/ T -- Being forced to write comments actually improves code, because it is easier to fix a crock than to explain it. -- G. Steele
Nov 28 2019