Dual conditions in D and Python

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 21 10:17:27 PDT 2015


On Thursday, 21 May 2015 at 16:57:16 UTC, Dennis Ritchie wrote:
> Hi,
> In Python I can write this:
>
> if (4 <= 5 <= 6):
>     print ("OK")
> -----
> http://rextester.com/NNAM70713
>
> In D, I can only write this:
>
> import std.stdio;
>
> void main() {
>
>     if (4 <= 5 && 5 <= 6)
>         puts("OK");
> }
> -----
> http://rextester.com/FICP83173
>
> I wanted to ask what is the reason? Maybe the program on 
> Python's slower because of this? Or legacy C/C++ affected D?

http://wiki.dlang.org/Language_Designs_Explained#Why_does_D_not_support_chaining_comparison_operators.3F


More information about the Digitalmars-d-learn mailing list