lua-users home
lua-l archive

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

On Sat, Apr 29, 2017 at 1:36 AM, Jay Carlson <> wrote:
> My favorite method (but alas the one I use least) is to parse a string at runtime and turn it into a Lua function. So taking the Wikipedia LINQ C# example, it would look something like:
> results =  linq[[
>   from c in SomeCollection
>   where c.SomeProperty < 10
>   select new {c.SomeProperty, c.OtherProperty} ]]
> for result in ipairs(results) do
>   print(result)
> end

I did something like this for constructing queries for columnar data:

(see the examples for

The trick was to convert the pseudo-SQL into equivalent Lua, which is
then loaded. Gotta love eval() in all its forms ;)

As for macros, I was a believer. But experience suggests that ad-hoc
syntax has to be very carefully designed - harder than writing good
libraries.  Design sense is relatively rare in the universe.