lua-users home
lua-l archive

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

On Wed, 24 Nov 2021 at 14:46, Michal Kottman <> wrote:
> Nice to see you back on the List!
> On Wed, Nov 24, 2021, 17:21 steve donovan <> wrote:
>> It is meant for people who remember the Lua standard library more than
>> the more obscure utilities, like 'cut' etc. For what we might call
>> 'personal automation' :)  It is also a very expressive calculator...
> I once toyed with a slightly related idea - I had a series of nontrivial formulas and wanted to see how the output reacts to changing inputs. It was unfortunately more than 2 inputs so "graphing it in Excel" was out of the question. But the interactivity of Excel left me wondering, if something like this can be implemented as a REPL with Lua formulas.
> The base idea was to (ab)use metatables with __[new]index on _G to construct an AST on the fly from the formula being entered, with two "types" - var{} and exp{...}, and store their values as a "snapshot" that gets re-evaluated with all dependent exp-s at every input. So basically you could say 'a = 1; b = sin(a*math.pi); c=math.sqrt(b)' and later on every time you change 'a' you can also see 'b' and 'c' changing simultaneously. Unfortunately due to the way Lua is implemented, comparisons (<, ==, ~=) can't be "virtualized", but this was enough for my case.

LuaGravity implemented something like this, it was a project made by
Francisco Sant'Anna's in his MSc thesis!
cool demo: