Inverted syntax: Difference between revisions

Content deleted Content added
Bartj (talk | contribs)
Added Bracmat
Line 23:
 
The task is to demonstrate support for inverted syntax forms within the language by showing both the traditional and inverted forms.
 
=={{header|Bracmat}}==
The match operator <code>:</code> can play the role of an inverted assignment operator <code>=</code>. The following two definitions of a function <code>double</code> are equivalent.
<lang>
double=.!arg+!arg;
 
(=.!arg+!arg):(=?double); { inverted assignment syntax, same result as above. }
</lang>
Bracmat evaluates all left hand sides of all binary operators. How right hand sides are treated depends on the operator. The <code>=</code> operator does not evaluate its right hand side at all. The right hand side of the <code>:</code> operator is evaluated by a dedicated match evaluator, which for example sees the expression <code>?double</code> as a variable to be bound to some part of the left hand side of the <code>:</code> operator.
 
The following two assignments are not equivalent:
<lang>foo=3+7 { assigns 3+7 to foo }
3+7:?foo { assigns 10 to foo }
</lang>
 
=={{header|CoffeeScript}}==