lua-users home
lua-l archive

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


2015-07-28 15:26 GMT+02:00 Soni L. <fakedme@gmail.com>:
> Currently these are the signatures for tostring and type:
>
> tostring (v) -> string
>
> type (v) -> string
>
> Would it hurt to change them to:
>
> tostring (v, ...) -> string, ...
>
> type (v, ...) -> string, ...
>
> (Similarly for math.tointeger/math.type/io.type, maybe also os.getenv, etc)

Vararging a parameter list is a breaking change, even if it is fully
backwards compatible with one-argument calls, because

    tostring(myfun(foo))

will currently keep only one of the return values of "myfun". You will
need to insert parentheses in order to preserve that behaviour.

In my reply to a previous post [1] of yours, I referred to a package
that inter alia offers item-by-item evaluation of a one-argument function
over a vararg.

[1] http://lua-users.org/lists/lua-l/2015-04/msg00225.html