Can Nelua's preprocessor/macro be used alone (as a Lua library)? #189
-
Mainly, I would like to use macros in configs. E.g. for NeoVim. Currently, I use Fennel for that, but I want to replace that with nelua. NeoVim uses Lua 5.1 (because of LuaJIT). Would that create any problem? if it helps, the workflow will be something like: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It is possible with lot of limitations and quirks, so I don't recommend that, thus I would say no. Nelua can compile back to Lua, this allow using its preprocessor and type checking for Lua, however the Lua backend is not maintained anymore, it was done in the early days for parsing and testing purposes. Nowadays the Lua backend is unmaintained and lots of stuff will give compile time errors. Here is an example of you asked: ## MYCONFIG = true
## if MYCONFIG then
print 'hello from lua'
## end $ nelua test.nelua --generator lua -o test.lua
$ cat test.lua
-- Generated by Nelua 0.2.0-dev
-- Compile Hash: mFdHCahpdZ8woTtsei8ecRHJehC
print("hello from lua")
$ lua test.lua
hello from lua So using ## MYCONFIG = true
## if MYCONFIG then
print 'hello world'
local t = {}
print(#t)
## end
This happens because For you use case, remember that Lua is a dynamic language, you can meta program your configs in Lua itself, no need to plug in an extra compiling step to personalize Lua configurations. |
Beta Was this translation helpful? Give feedback.
It is possible with lot of limitations and quirks, so I don't recommend that, thus I would say no.
Nelua can compile back to Lua, this allow using its preprocessor and type checking for Lua, however the Lua backend is not maintained anymore, it was done in the early days for parsing and testing purposes. Nowadays the Lua backend is unmaintained and lots of stuff will give compile time errors.
Here is an example of you asked:
$ nelua test.nelua --generator lua -o test.lua $ cat test.lua -- Generated by Nelua 0.2.0-dev -- Compile Hash: mFdHCahpdZ8woTtsei8ecRHJehC print("hello from lua") $ lua test.lua hello from lua
So…