[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: DSL in lua
- From: Vasiliy Tolstov <v.tolstov@...>
- Date: Thu, 6 Dec 2012 10:48:22 +0400
Thanks. But = sign i think is ambigious... How can i avoid using = sign?
2012/12/6 Dirk Laurie <dirk.laurie@gmail.com>:
> You're a few commas away from legal Lua syntax.
>
> directory "/etc/" {
> owner "root",
> group "wheel",
> mode "0755",
> action "create",
> }
>
> It can be done (functions owner etc would have to store
> their argument somewhere) but a few equal signs makes the
> Lua code efficient:
>
> directory "/etc/" {
> owner="root",
> group="wheel",
> mode="0755",
> action="create",
> }
>
> The code would be (not tested):
>
> function directory(dirname)
> return function(t)
> os.execute ("mkdir %s; chown %s.%s %s; chmod %s %s"):
> format(dirname,t.owner,t.group,dirname,t.mode,dirname)
> end
> end
>
> Or one could replace the `{`..`}` by `[[`..`]]` and insert
> a small parser that extracts the fields from the string.
>
--
Vasiliy Tolstov,
Clodo.ru
e-mail: v.tolstov@selfip.ru
jabber: vase@selfip.ru