lua-users home
lua-l archive

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


On Sat, May 2, 2009 at 9:59 AM, steve donovan wrote:
> Any methods which are not recognized are looked up using the first
> value of the sequence:
> S{'[one]','[two]','[three]'}:sub(2,-2):upper():printall() ---> ONE TWO THREE

Caching of the first function goes against dynamic binding.

It would be nice to be able to switch between a sequence and table
implementation merely by switching the implementation of S (as memory
and performance requirements change).

The method chaining can also be made to have the semantics of Forth
(the input to each filter being the previous stack).

On Sat, May 2, 2009 at 1:37 AM, Mark Hamburg wrote:
> 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.

This would also allow non-alphanumeric method names:

z = N(x):['2 * x^y'](n):['x + 1/x']()()
   -- same as z = 2 * x^n + 1 / (2 * x^n)
   -- where methods are created on the fly
   -- via http://lua-users.org/wiki/ShortAnonymousFunctions