mani-language / Mani

Máni ... an awesome, super simple programming language!
https://mani-language.github.io/
Mozilla Public License 2.0
28 stars 7 forks source link

++ and -- operators. #4

Closed crazywolf132 closed 6 years ago

crazywolf132 commented 6 years ago

Much lie #1 , we should really add the ++ and -- operators to objects.

eg:

let a = 5;
a++; // a now = 6;

and

let a = 5;
a--; // a now = 4;

If we wanted to make this language stand out a bit, we could incorporate something unique... if the operator is on the left of the variable: ++a; means it will double the effect.

eg.

let a = 4;
++a; // a now = 6;

and

let a = 4;
--a; // a now = 2;
crazywolf132 commented 6 years ago

Claimed by @brokenprogrammer

crazywolf132 commented 6 years ago

This might have been unclear initially, but it needs to save back to the variable... eg.

>> let a = 1;
>> a++; // Actually increments the value of a by 1, and saves this value
>> say a;
2
crazywolf132 commented 6 years ago
>> let a = 12;
>> say a;
12
>> a++;
>> say a;
13
>> ++a;
>> say a;
15
>> a--;
>> say a;
14
>> --a;
>> say a;
12

Reopened so we can add the latest changes to the doc. #15

Will close once added.