lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have a lot more code using _G than hyperbolic trig. Possibly +inf times more.

sed -i "s/\b[_G]\b/[_ENV]/g" *.lua

This is one kind of doing forward compatibility that is so easy to do. If you need a recursive version:

find -name "*.lua" | xargs sed -i "s/\b[_G]\b/[_ENV]/g"

(I didn't test both so use with coution)

The same with new keywords, I don't get all the complaints about a new keywords, when in fact it is in most times very little to adapt. For example moved C code to be C++ there is for example a new keyword "class", which some code used. Well search/replace with "elementClass" done. Finished in a few minutes...

I know one can construct obscure examples where Lua reflection ability (that is input/output interacts with field names) can disturb things what can't happen in C/C++ but honestly, they are likely to be very rare.