lua-users home
lua-l archive

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




On Sun, Mar 27, 2011 at 1:20 PM, Frank Meier-Dörnberg <frank@md-web.de> wrote:
Ideally, a library knows best how to handle a complex _expression_ of their own objects. [...]
Could Lua call my mydream library with the AST of "A=(B * C + D) * E" instead of evaluating it itself somehow?

At compile-time, with a dynamically type language, you don't know the types of A, B, C, D, E, so you have no idea which library could handle them. At runtime, either the AST is lost, or you have to perform some sort of re-compilation step, which would be grossly expensive in time and resources.

What you're proposing would be doable in a statically-typed language--C++ templates are not that far away from that, actually--but you can't have that in something that even remotely feels like Lua.

-- Fabien.