lua-users home
lua-l archive

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

On Thu, Sep 2, 2010 at 6:12 AM, François Perrad
<> wrote:
> 2010/9/2 steve donovan <>
>> My first thought when reading 'CodeGen' is that it has to do with
>> _code generation_, not templating.
> templating is one way of code generating.
> But templating is often associated/dedicated to HTML generation which is not
> my only purpose.

My first thought also was this was related to the generation of
executable code [1] or maybe Lua byte codes like lcode.c, which is the
"Code generator for Lua".  Rather, it's a templating system.  A
"return Template {...}" would seem more clear to me--i.e. it's
returning a template object--than "return CodeGen {...}", which is
returning a "code gen", whatever that is.  The module is probably not
setup as a Lua preprocessor in the manner of CPP.  It probably is
lightweight enough to be used for code generation inside [2], though I
might opt for something even simpler [3]. It is a fairly simple module
to understand and use, and that's a significant quality (single 250
line file with no dependencies).  Whether there's sufficient
flexibility in that simplicity for its use cases, I don't know without
using it.

I don't really like the syntax ${dependencies:_depend()} meaning "call
depend for each item of the array dependencies".  That I interpreted
as the actual Lua code "dependencies:_depend()".  It does have some
similarity to the pattern of a method call on an array being applied
to all members of the array [4].  However, as done it suggests that
_depend is a field of dependencies as in dependencies["_depend"],
which I don't think is the case.

(BTW, this type of discussion might belong in the proposed "Lua
Modules Development List".)