Just saw this code snippet posted on the Facebook Delphi Developer group, a Pascal version of the C/C++/C# ternary conditional ?: operator in DWS:

Just saw this code snippet posted on the Facebook Delphi Developer group, a Pascal version of the C/C++/C# ternary conditional ?: operator in DWS:
"ColorToWebStr(FColor, if Transparent then 0 else 255);
Which is equal to C#'s:
ColorToWebStr(FColor, Transparent? 0 : 255);"

Wouldn't that be nice in Delphi? It's one of the things I really miss moving from C++ - that and RAII.

Comments

  1. David Schwartz Amen.

    And while syntax changes and simplifications with no side effects are ignored, we get changes like the zero-based strings which are based on a unit-level compiler switch... that was oh-so-necessary, it reduced and simplified code... NOT.

    ReplyDelete
  2. Eric Grange Worse, we have a sort of neither fish nor fowl setup where we can actually be in a mixed mode of zero-based and 1-based strings, depending on what routines are called.

    ReplyDelete
  3. I t really bugs me when people argue against useful language changes just because another language has the same syntax... my argument is so what.. if it's useful/concise in c# then it'll be just as useful/concise in Delphi. And the best part is, like the with statement, if you don't like it, don't use it!

    ReplyDelete

Post a Comment