lua-users home
lua-l archive

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


On Sat, Dec 15, 2012 at 1:10 AM, Andrew Starks <andrew.starks@trms.com> wrote:
> Never use ordered arguments for function calls to an API. What is the
> point of the order ordered arguments? Is the third-ness of the third
> argument to a method helpful to me? Is that more memorable than
> saying:
>
> my_func{iPhone = "auto correcting type writer", writing = lua,
> at_night = "is a pain in the butt"}

I'm pretty sure there's a performance penalty involved in creating a
new table and extracting the arguments from it versus ordered
arguments. It's probably not something to worry about in most cases,
but if speed is important, it's something that might be an issue.

While an invocation like log{what="my message", where=output_file,
why="warning"} is valid, it seems ugly to me. I usually prefer that
syntax for functions that take some kind of table/object/list as a
parameter, especially if they're going to modify it in some way (add
metamethods?) and return it. Then it feels more like tagging or
creating an object, and less like an ugly function call. :-)

-- 
Sent from my Game Boy.