-
-
Notifications
You must be signed in to change notification settings - Fork 78
MetaProgramming
Meta programming allows you to extend NPL syntax using the NPL language itself. For example, following code are valid in NPL.
local a=1;
loop(){ please execute the code 10 times with i
echo(a+i)
async(){
echo("This is from worker thread");
}
}
Here loop, async are extended NPL syntax defined elsewhere.
The concept is first developed by LISP programming language in 1960s. However, despite the power of LISP, its syntax is hard to read for most programmers nowadays. NPL introduces a similar concept called Function-Expression
, which can be mixed very well with the original NPL syntax.
The syntax of NPL's Function-Expression is name(input, ...){ ... }
Files with *.npl
extension support Function-Expression syntax by default. For example
NPL.load("(gl)script/tests/helloworld.npl")
NPL.loadstring("-- source code here", "filename_here")
TODO for popeye:
TODO for popeye:
For more examples, please see our test here
Download Paracraft | ParacraftSDK | copyright by tatfook 2016 | upload image