lua-users home
lua-l archive

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

I think one poster upthread mentioned something like this, but my 2 cents:

Chaining is not necessarily a good thing: obj:a():b() and more complex chains are potential bugs lurking unless:

1. This are no failure points possible except in the final index operation.

2. (Needed to facilitate #1) the intermediate index operation are designed for chaining.

I mostly don't find chaining worthwhile.

Full disclose: One exception for me is multiple levels of table indexing: local x = a.b.c.d.e where a is a table and b, c, and d are subtables when they exist. I use metatable trickery to assure the expression returns nil rather than crashing if b, c, or d don't exist.