lua-users home
lua-l archive

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


On May 1, 2009, at 8:42 PM, David Manura wrote:

 f = chain(stringx):trim():repeatchars(5):upper()

This potentially leads to:

	f = chain( string, stringx ):trim():repeatchars(5):upper()

thereby eliminating the need for adding the methods from string to stringx.

On a potentially related note, I had previously been thinking about ways to do chaining/pipelining for iterator construction. As I recall, that had lead to constructs like:

pipe( pairs, map( function( k, v ) return tostring( k ), tostring( v ) end ), filter( function( k, v ) return #k == 3 end ) ) ) ( t )

Those had never felt as clean as one might like, however, though they did encourage saving the pipe for reuse. Perhaps there's something to be explored in your chain solution.

Mark

P.S. The obj:[ method ] syntax suggestion actually arose out of wanting to make it easier to call variable methods without expanding the colon operator and thereby muddying the waters about the intent of the code.