lua-users home
lua-l archive

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


2012/11/17 David Favro <lua@meta-dynamic.com>:
> On 11/17/2012 03:47 AM, Dirk Laurie wrote:
>>
>> Lua has no variables (i.e. preallocated named blocks of memory
>> the contents of which may change)
>
> Except for local variables, including function parameters, for-loop
> variables, etc.
>
You're right. Indeed, those correspond closely to the definition
in parentheses.

For function parameters, even I might support C-like syntactic sugar:

   function myfunc (number a, string b, table c)

if only because most of my functions start off something like

if type(a)~="number" then error(
  "Bad parameter #1to myfunc: number expected, got "..type(a))

The semantics would be that if there are two whitespace-separated
names, the appropriate argument check is made (the API already
has the necessary routines), otherwise it's business as usual.