lua-users home
lua-l archive

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




2012/12/13 Sven Olsen <sven2718@gmail.com>
    object.member_function
        (some, collection, of, parameters)

I haven't often seen the second pattern used in the wild -- though for programmers who prefer it, I'm sure 5.1's ambiguous syntax error would have been an annoyance.

I haven't seen it as shown above but I've seen the below quite often (especially when there are lots of verbose arguments)

object:DrawText2d
(
    0,
    0,
    "Hello world",
    Color:Create(1,1,1,1),
    Align(center, center)
)

The soil image loading library has this type of call in it's documentation http://www.lonesock.net/soil.html (of course it's not Lua because otherwise the author would have run into the issue of it being invalid in 5.1)

I prefer 5.2, only as it seems more consistent, previously you could write a function that takes a table as a first argument like this:

myfunction
{
    arg1 = "value",
    arg2 = "value"
}

but you wouldn't be able to format it the same way if you just had a list of arguments.