-
Notifications
You must be signed in to change notification settings - Fork 14
4. Operations and symbols
This page lists all operators and symbols available in Clue.
-
+
Addition -
-
Subtraction -
*
Multiplication -
/
Division -
/_
Floor division -
%
Modulo -
^
Exponentiation
These operators remain unchanged from Lua except floor division.
-
==
Equals -
!=
Not equals -
<
Less than -
>
Greater than -
<=
Less than or equals -
>=
Greater than or equals
Only the not equals operator changed: !=
must be used instead of ~=
-
&&
Lua'sand
keyword -
||
Lua'sor
keyword -
!
Lua'snot
keyword
Lua's keywords are replaced by symbols, but they work exactly the same.
While ternary is possible in Lua with condition and x or y
it is not identical to C's ternary
(if condition
is true but x
is nil or false it will return y
).
Clue adds ?
and :
that replicate true ternary when compiled (if condition
is true x
will be returned no matter what).
local a = x ? y : z;
This code will be compiled to:
local _t0;
if x then
_t0 = y;
else
_t0 = z;
end
local a = _t0;
-
=
Redefine -
+=
Increase -
-=
Decrease -
*=
Multiply -
/=
Divide -
^=
Exponentiate -
..=
Concatenate -
%=
Module -
&&=
Define if itself is true -
||=
Define if itself is false -
??=
Define if itself is nil
All of these except =
were added by Clue, click here for more info about them.
-
&
AND -
|
OR -
^^
XOR -
~
NOT -
<<
Left shift -
>>
Right shift
When compiling Clue will assume the version of Lua you're compiling to supports bitwise operations and uses the same symbols that Clue uses.
If you're using LuaJIT you can use the -jitbit
flag to make Clue load the bit
library and use it for bitwise operations.
You can choose the name of the variable that stores the bit
library, and you will be able to use the library yourself with the same variable.
(For example, to name the variable bit
: --jitbit=bit
)
-
.
String-keys indexing -
[]
Normal indexing -
::
Method indexing -
?.
Conditional.
indexing -
?[]
Conditional[]
indexing -
?::
Conditional::
indexing
Clue adds conditional indexing and replaces :
with ::
.
-
=
Define -
#
Length -
;
End of expression -
...
Variable amount of function arguments -
$
Pseudo variable
-
?>
PGet, removed entirely (b2.0.86) -
?=
Replaced by&&=
(3.0.0) -
:=
Replaced by||=
(3.0.0)