Inverted syntax: Difference between revisions

Latitude language added
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Latitude language added)
Line 519:
Do I need an umbrella? Yes
</pre>
 
=={{header|Latitude}}==
 
Latitude, by default, does not support inverted conditionals, as its two primary means of conditional branching both involve the condition first.
 
<lang latitude>local 'raining = True.
local 'needUmbrella = False.
 
if (raining) then {
needUmbrella = True.
} else {}.
 
{ raining. } ifTrue {
needUmbrella = True.
}.</lang>
 
However, such constructs can easily be added to the language.
 
<lang latitude>#'Method when := {
localize.
if ($1) then {
this.
} else { }.
}.
 
#'Method unless := {
#'self when ($1 not).
}.
 
;; Example usage
{ needUmbrella = True. } when (raining).
{ needUmbrella = True. } unless (raining not).</lang>
 
Likewise, inverted assignment syntax is not supported natively, but it can be approximated in-language, using a definition similar to that of the built-in <code>local=</code>.
 
<lang latitude>global let= := { self slot ($2) = #'$1. }.
 
local 'a = 6.
println: a. ;; 6
 
let 6 = 'b.
println: b. ;; 6</lang>
 
=={{header|M2000 Interpreter}}==
37

edits