Re: Testing whether static foreach is available

2017-09-10 Thread jmh530 via Digitalmars-d
On Sunday, 10 September 2017 at 10:43:24 UTC, Petar Kirov [ZombineDev] wrote: Since Phobos always uses the latest compiler frontend, there's nothing to check ;) Here's an example of what I mean. In D 2.074.0, std.format added some compile-time format string functionality. So if I compile wi

Re: Testing whether static foreach is available

2017-09-10 Thread Moritz Maxeiner via Digitalmars-d
On Sunday, 10 September 2017 at 01:49:42 UTC, Mike Parker wrote: On Saturday, 9 September 2017 at 16:53:19 UTC, jmh530 wrote: version(DLANGSEMVER >= 2.076.0) { //include static foreach code. } but we can't do conditionals in version blocks, so you'd need a static if. Alternately, we'd also

Re: Testing whether static foreach is available

2017-09-10 Thread via Digitalmars-d
On Sunday, 10 September 2017 at 02:13:58 UTC, jmh530 wrote: On Sunday, 10 September 2017 at 01:49:42 UTC, Mike Parker wrote: But Adam's point about the false branch still holds, so: static if(__VERSION__ >= 2076) mixin(`static foreach(i; 0..3) writeln(i);`); else writeln("Version too l

Re: Testing whether static foreach is available

2017-09-10 Thread via Digitalmars-d
On Saturday, 9 September 2017 at 16:30:51 UTC, Jean-Louis Leroy wrote: Is there a way to test whether 'static foreach' is available, e.g. via a version symbol? Also, is it possible to conditionally compile depending on the compiler's version, not only the compiler (I mean, not compile a block

Re: Testing whether static foreach is available

2017-09-09 Thread jmh530 via Digitalmars-d
On Sunday, 10 September 2017 at 01:49:42 UTC, Mike Parker wrote: But Adam's point about the false branch still holds, so: static if(__VERSION__ >= 2076) mixin(`static foreach(i; 0..3) writeln(i);`); else writeln("Version too low"); The same is true for version statements. But it woul

Re: Testing whether static foreach is available

2017-09-09 Thread Mike Parker via Digitalmars-d
On Saturday, 9 September 2017 at 16:53:19 UTC, jmh530 wrote: version(DLANGSEMVER >= 2.076.0) { //include static foreach code. } but we can't do conditionals in version blocks, so you'd need a static if. Alternately, we'd also need a trait or something to get the semver of the compiler. A

Re: Testing whether static foreach is available

2017-09-09 Thread jmh530 via Digitalmars-d
On Saturday, 9 September 2017 at 17:32:54 UTC, Adam D. Ruppe wrote: std.compiler looks useful http://dpldocs.info/experimental-docs/std.compiler.version_minor.html Did not realize that was in there. TIL.

Re: Testing whether static foreach is available

2017-09-09 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 9 September 2017 at 16:30:51 UTC, Jean-Louis Leroy wrote: I did look at the docs, several times, couldn't find it... you should use my unofficial docs http://dpldocs.info/version std.compiler looks useful http://dpldocs.info/experimental-docs/std.compiler.version_minor.html sta

Re: Testing whether static foreach is available

2017-09-09 Thread Jean-Louis Leroy via Digitalmars-d
On Saturday, 9 September 2017 at 16:53:19 UTC, jmh530 wrote: On Saturday, 9 September 2017 at 16:30:51 UTC, Jean-Louis Leroy wrote: Also, is it possible to conditionally compile depending on the compiler's version, not only the compiler (I mean, not compile a block if it's GDC version 5.4.1 o

Re: Testing whether static foreach is available

2017-09-09 Thread jmh530 via Digitalmars-d
On Saturday, 9 September 2017 at 16:30:51 UTC, Jean-Louis Leroy wrote: Also, is it possible to conditionally compile depending on the compiler's version, not only the compiler (I mean, not compile a block if it's GDC version 5.4.1 or lower)? What you really need is a version statement based

Testing whether static foreach is available

2017-09-09 Thread Jean-Louis Leroy via Digitalmars-d
Is there a way to test whether 'static foreach' is available, e.g. via a version symbol? Also, is it possible to conditionally compile depending on the compiler's version, not only the compiler (I mean, not compile a block if it's GDC version 5.4.1 or lower)? I did look at the docs, several