lua-users home
lua-l archive

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




Egor Skriptunoff <egor.skriptunoff@gmail.com> 于2019年6月7日周五 下午2:20写道:
On Wed, Jun 5, 2019 at 6:17 PM Xavier Wang wrote:
So, we just do not append a '(' after the name, like this:
local x = a:integer + b:integer
It's invalid in current Lua.
or like this:
(a:integer[])[10]
for multiple annotations, this should works:
local x:toclose:MyClass = MyClass.new()



How the following should be interpreted:
   local x = a:MyClass(b:MyAnotherClass)
Does it mean
   local x = a.MyClass(a, b)
or
   local x = a(b)
?


It should be x = a.MyClass(a, b), and makes an error (because there is no MyClass in a), the correct way to write it:

local x = (a:MyClass)(b:MyAnotherClass)

It's just like "foo":format() is an error, you must write ("foo"):format()

and, you want call a as a function? why you need type annotation in this case?

--
regards,
Xavier Wang.