Quick Modifiers - jpbubble/NIL-isn-t-Lua GitHub Wiki

It was my desire to support stuff like this in NIL:

#include <std.io>
int main(void){
   int a = 4;
   a += 4;
   printf("%d",a);
   return 0;
}

With that I mean that "+=" quick modification command. Unfortunately I had some kind of complication on the short run, but I have put in a quick alternate solution, which will do for the short while.

int a = 4
#+ a 4
print(a)

That will have the same effect in NIL as the C program had above.

It also works on strings

string A = "Hello "
#+ A "World"
print(A) // outputs: Hello World
string B = "="
#* B 5
print(B) // outputs: =====

I want to note that this is in a kind of primitive state, and the variable checking is not yet as thoroughly as normal. Also arrays and tables can be a core this does not work:

#+ a["hello"] 1

This will #+ a.hello 1


Using the C syntax is a longer term desire, and if implemented the current setup may be 'soft-deprecated' (although the deprecation period may be pretty long, and for backward compatibility reasons even be 'eternal'). Also if used on undeclared variables the system still tries to work this out, and it goes without saying that 'nil' values are not allowed to work out this way.

## NOTICE:
This only works if NIL has been ported as "NIL"... if you write 'NNN = require "NIL"' then it won't work.
⚠️ **GitHub.com Fallback** ⚠️