<div dir="ltr"><div dir="ltr">On Wed, Nov 6, 2019 at 2:01 AM Sven Barth via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto">A normal if-statements has the same non-evaluation.</div></div></blockquote><div><br></div><div>Not in the way I meant, though. </div><div><br></div><div>Like, I thought the difference between "normal if" and "ternary if" was supposed to be the same as the difference between the existing IfThen() function and the intrinsic version of IfThen(), on which you based the "if-then-else" syntax I think. </div><div><br></div><div>By which I mean, something similar to the difference between "if" and "static if" in the D programming language (at least when given things that are possible to evaluate at compile time, like GetTypeKind is in Pascal). For example:</div><div><br></div><div>import std.stdio;<br>import std.traits;<br><br>// Would not compile, because everything is evaluated fully,<br>// and in this case the parameters we pass aren't<br>// compatible with all branches.<br>void PrintSomething(T)(T value) {<br>  if (isFloatingPoint!(T)) {<br>    writefln("Floating point value: %f", value * value);<br>  } else if (isIntegral!(T)) {<br>    writefln("Integral value: %d", value * value);<br>  } else if (isSomeString!(T)) {<br>    writefln("String value: %s", value ~ value);<br>  }<br>}<br><br>// Compiles fine, as only the relevant branch for<br>// a given parameter is evaluated.<br>void StaticPrintSomething(T)(T value) {<br>  static if (isFloatingPoint!(T)) {<br>    writefln("Floating point value: %f", value * value);<br>  }<br>  else static if (isIntegral!(T)) {<br>    writefln("Integral value: %d", value * value);<br>  }<br>  else static if (isSomeString!(T)) {<br>    // "~" does string concatenation in D<br>    writefln("String value: %s", value ~ value ~ value);<br>  }<br>}<br><br>void main() {<br>  StaticPrintSomething(1);<br>  StaticPrintSomething(1.0);<br>  StaticPrintSomething("hey");<br>}<br></div><div><br></div><div>The point being that the type-checking is neither useful or necessary in scenarios where the branch being evaluated is statically known to be unreachable ahead of time.</div></div></div>