lua-users home
lua-l archive

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


On Fri, May 15, 2009 at 6:55 AM, David Manura <dm.lua@math2.org> wrote:
> Steve's chained method calls that apply to all elements in a collection [2],
>
>  S{'[one]','[two]','[three]'}:sub(2,-2):upper():printall() -->
> output: ONE TWO THREE
>
> reminded me of jQuery [3].  I think there may be other applications of
> this design pattern.  As a test, [1] implements a basic string
> pattern/substitution library along this idea.
>

As fans of jQuery we're already doing this kind of thing a lot in Lua.

For example we use it to generate XML ready to send across the wire in
XMPP: http://prosody.im/doc/developers/util/stanza (examples at the
bottom)
with the code here: http://prosody.im/source/browse/?file/tip/util/stanza.lua

We also have (currently uncommitted) code for matching in a similar
fashion, to extract a specific tag or text from an XML tree.

It is an extremely easy style of API to use, and it really would be
great to see it in more places in Lua.

Matthew.