lua-users home
lua-l archive

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


Sunshilong, If you want something like named parameters (aka named
arguments or keyword arguments), you can emulate that in Lua using
tables:
    foo{a = 10} -- error: parameter 'b' is required
    foo{a = 10, b = "meh"} -- error: parameter 'b' must be a number
    foo{a = 10, b = 123} -- error: parameter 'b' must be greater than
0 and less than 100
    foo{a = 10, b = 20} -- ok
That table is passed as the first argument into 'foo'. Not exactly
what you wanted, but I think you wanted something like this.
---

Sean Conner, so when the source code is available [from file or
string], it is possible to print the line or the most relevant part of
that line. We can't have line number information for C code from lua,
so there is the '[?]'. But when the source code *is* available, I
think printing the lines itself along with the error is helpful.
--Sudipto Mallick