lua-users home
lua-l archive

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



I was implying the type names would be keywords, which makes the syntax work.

Maybe having 'function' first would anyways be better, helping Lua lexer to know what's coming...

   local function string dummy( ...

Anyways, your suggestion is good, too, especially the '?' for optional marker I like.

How about multiple allowed types, say either string or table:

local function dummy(t:string:table, i:int, j:int?, n:number?):string:table

That is awfully close to meaning a table of strings.... Ideas?

(btw, I had intentionally used both int and number. They'd remain the same "number" type, where int means a non-fractional subset of "number". Useful for commentary reasons, and runtime sanity checks.)


On Mon, 31 Jul 2006 09:55:12 +0700
 Vyacheslav Egorov <mraleph@gorodok.net> wrote:
Asko Kauppi wrote:

local string function dummy( table t, int i, optional int j, optional number n )
    ...
    local int x= i + (j or 0) + (n or 0)
    return string t[x]
   end

This syntax is ambiguous. It already have meaning

local string         -- new local variable
function dummy (...) -- new global function
...
end

I think Pascal-style is more suitable for Lua than C-style:

local function dummy(t:table, i:int, j:int?, n:int?):string
...
end

--
e.v.e