lua-users home
lua-l archive

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


On Wed, Dec 15, 2010 at 06:56:12AM +0200, David Manura wrote:
> you'd probably prefer it in the
> form of slices instead: `t[3:6] = ...` (i.e. replace elements 3
> through 6 with the elements in the vararg list).

Two extensions to Lua needed:
    3:6             --> {3,4,5,6}
    a[{3,4,5,6}]    --> {a[3],a[4],a[5],a[6]}
Will this break many programs?  I doubt it: table-valued keys
are close to useless.
> a[{1,2}]='s'
> print(a[{1,2}])
nil
At present a table-valued key hashes the address of the table.
You can't use it, as I tried above, to simulate double indexing.

The lexical analyzer will have to handle str:find(...) as a call
to an overloaded function __colon(str,find)(..) (or whatever) 
instead of as syntactic sugar.  May be hard to do.

Dirk