Expression-oriented programming language: Difference between revisions

Content deleted Content added
FrescoBot (talk | contribs)
m Bot: links syntax and spacing
Line 5:
==Criticism==
 
Critics<!--[[Assignment_(computer_science)#Assignment_versus_equality|Assignment versus equality]]</ref><ref>[[Relational_operator#Confusion_with_assignment_operators|Confusion with assignment operators]]</ref>-->, including language designers,<ref>[http://java.sun.com/docs/codeconv/html/CodeConventions.doc9.html#547 Java Code Conventions "10.4 Variable Assignments"]</ref> blame expression-orientation for an entire class of [[software bug|programming mistake]] wherein a programmer introduces an [[Assignment_(computer_science)|assignment expression]] where they meant to test for [[Equality_(relational_operator)|equality]]. For example, the designers of [[Ada_(programming_language)|Ada]] and [[Java_(programming_language)|Java]] were so worried about this type of mistake, they restricted [[Conditional_(programming)|control expressions]] to those that evaluate strictly to the [[Boolean_data_type|boolean data type]].<ref>[http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#5991 Java Language Specification "14.9 The if Statement"]</ref><ref>[http://www.adaic.org/whyada/intro4.html Introducing Ada]</ref> The designers of [[Python_(programming_language)|Python]] had similar worries but took the alternative strategy of implementing assignment as a statement rather than an expression, thus prohibiting assignment from nesting inside of any other statement or expression.<ref>[http://docs.python.org/reference/simple_stmts.html#assignment The Python Language Reference "6.2. Assignment statements"]</ref>
 
However, [[notation]] provokes such errors, not [[semantics]]. From the perspective of expression-orientation, the choice of [[Assignment_(computer_science)|assignment notation]] made by [[Curly_bracket_programming_language|C-style languages]], the [[equals sign]], <code>=</code>, can be considered a poor choice due to the equals sign's similarity to, and hazardously small [[Typing#Minimum_string_distance_error_rate|typing distance]]<ref group="nb" name="distance">In fact, considering the automatic repetition feature of [[Keyboard_(computing)|typical computer keyboards]], the [[Typing#Minimum_string_distance_error_rate|minimum string distance]] between <code>[[Assignment_(computer_science)|=]]</code> and <code>[[Equality_(relational_operator)#Equality|==]]</code> is effectively zero, the ''worst possible'' collision.</ref> from the notation C-style languages choose for the equality operator, <code>==</code>, make it an occasion for error. The expression-ness of assignment is not the root cause. Other language families make different notational choices for assignment<ref>{{Cite web