lua-users home
lua-l archive

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

On Mon, Sep 28, 2009 at 2:35 AM, Thomas Harning Jr. <> wrote:
> managed through accessors.  Now... if you have a typo when accessing
> members of tables, that can be problematic.. though it's less likely
> than typos when accessing items you intend to be in local-scope.

With a little discipline, field name typos can be caught usefully:


struct.Point {X = 0, Y = 0}

p1 = Point() -- defaults to {X=0,Y=0}
p2 = Point {X=2,Y=10}

print(p1.x)  ---> oops! No such field!

The other advantage is that it encourages developers to name all those
anonymous data structures which we create so happily and then struggle
to document.

steve d.