[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Data transformation templates
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 8 Jan 2014 17:08:51 +0200
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...