-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I have added logical and/or functions and operators with a low precedence. It makes relational operators more C/C++/C#/Java/JavaScript/Python -like. Using bitwise and/or for comparison requires parenthesis that logical and/or does not. (see code snippet below)
print "a=", 2>1 & 3>1
print "b=", (2>1) & (3>1)
print "c=", 2>1 && 3>1
ouputs:
a=0
b=1
c=1
{ "&&", BINOP(5), (intptr_t)logicaland },
{ "||", BINOP(5), (intptr_t)logicalor },
static Val logicaland(Val x, Val y) { return x&&y; }
static Val logicalor(Val x, Val y) { return x||y; }
Speaking of being C-like, the BNF in the readme.md shows '==' for the equality operator, but the code actually uses '='. I have changed mine to '=='. I have also changed the inequality operator from the BASIC/Pascal-like '<>' to the C-like '!='. I realize changing them would break existing scripts, but for new users of TinyScript I think it makes sense.
I've also added a bitwise not and an Elvis operator. Maybe I am getting operator crazy?
I would rather discuss all this before submitting a pull request, as I want to improve the language, not change it.