D vs nim

Mark smarksc at gmail.com
Fri May 4 16:36:49 UTC 2018


On Thursday, 3 May 2018 at 23:09:34 UTC, Timothee Cour wrote:
> nim supports static if (`when`) + CTFE. A simple google search 
> or searching
> would've revealed that.
>
> On Thu, May 3, 2018 at 3:20 PM Mark via Digitalmars-d < 
> digitalmars-d at puremagic.com> wrote:
>
>> On Thursday, 3 May 2018 at 20:57:16 UTC, Dennis wrote:
>> > On Thursday, 3 May 2018 at 19:11:05 UTC, Mark wrote:
>> >> Funnily, none of these languages have a "static if" 
>> >> construct, nor do Rust, Swift and Nim. Not one that I could 
>> >> find, anyway.
>> >
>> > What qualifies under "static if"? Because Rust, Swift and 
>> > Nim do have conditional compilation.
>> >
> https://doc.rust-lang.org/book/first-edition/conditional-compilation.html
>> >
> https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html (conditional compilation blocks)
>> >
> https://nim-lang.org/docs/manual.html#statements-and-expressions-when-statement
>
>> Fair enough. I should have written "static if + CTFE".

The little information on the official site describes `when` more 
like #ifdef in C than an actual static if. I also went over a few 
dozens of modules in the standard library and the statement seems 
to be rarely used, and when it does it's usually in an #ifdef-ish 
context (like platform specific code).

Perhaps Nim's support for conditional compilation is as powerful 
as D's is, but you can see why my impression is currently to the 
contrary.


More information about the Digitalmars-d mailing list