lua-users home
lua-l archive

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


On Wed, Jan 8, 2014 at 3:52 PM, Javier Guerra Giraldez
<javier@guerrag.com> wrote:
> buildmap([[
>     out = {
>         sprite = '/img/'..in[1],
>         x = in[2], y = in[3]
>     }
> ]])(data)
>
> but i don't like it...

I know what you mean, it feels like stunt programming. Can drop parens
around the [[..]] and memoize, and then it's pretty efficient.  (Note
this where text templates can generate code for structural templates).
 Lack of (fast) access to upvalues is where these tricks show their
weakness, of course.

I did use the codegen trick for Penlight's data module, to support the
pseudo-SQL notation efficiently.

But I find the general challenge interesting; to construct a Lua DSL
for expressing structure templates...