Code: Select all
!!local TWO_PI = 2 * math.pi
Code: Select all
!local TWO_PI = 2 * math.pi
local TWO_PI = !(TWO_PI)
I admit, assignments using !! is probably the least useful feature of the preprocessor and I only use it myself in very few places, usually in the following case...
In the metaprogram in my files I never create globals (with a couple of exceptions**). This way I only need to preprocess files that have changed since the last run before I run the game again (as the output will always be the same for unchanged files), and thus the preprocessing step is quicker.
Anyway, a file may do something like this:
Code: Select all
!local foo = someValue
-- Later in the file I use !(foo) in multiple places.
Code: Select all
_G.!(local )!!foo = someValue
-- ...which essentially means:
_G.
!local foo = someValue -- It's ok to put metaprogram code "in the middle" of normal code.
foo = !(foo)
** I have a couple of files that do declare globals for the metaprogram, and if any of those change then I preprocess every single file again as any file may have gotten affected by the changes.