[M3devel] in defense of ternary operator (Ada has it now)

Jay K jay.krell at cornell.edu
Wed Oct 17 03:08:01 CEST 2012


In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator:
e.g.
  sign := if a >= 0 then 1 else -1 
They'd rather people NOT do like:
  sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 
 http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf 
 "It should be remembered that the difficulties in C stem from a combination of things   - That assignment is permitted as an expression,   - That integer values are used as Booleans,    - That null statements are invisible. 
  None of these applies to Ada so all is well"    Modula-3 is also safe from the first two, I don't know about the last.  - Jay 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20121017/0186edc7/attachment-0001.html>


More information about the M3devel mailing list