Function 我不知道的一段Lua语法';我不明白

Function 我不知道的一段Lua语法';我不明白,function,syntax,lua,Function,Syntax,Lua,我使用的是基于Lua的产品,我使用的是他们的API,其中有一些语法我不理解 这是什么? 它是Add的函数调用吗?如果是,输入参数是什么?没有将该表分配给变量输入-没有等号 这是Add的函数定义吗?这看起来很奇怪,没有任何实现,也没有指定输入表中的内容 是否添加包含表的表?我从未见过用括号而不是大括号创建的表格 serviceDefinitions.Add( input { name="p1", baseType="NUMBER", description="The first adden

我使用的是基于Lua的产品,我使用的是他们的API,其中有一些语法我不理解

这是什么? 它是Add的函数调用吗?如果是,输入参数是什么?没有将该表分配给变量输入-没有等号

这是Add的函数定义吗?这看起来很奇怪,没有任何实现,也没有指定输入表中的内容

是否添加包含表的表?我从未见过用括号而不是大括号创建的表格

serviceDefinitions.Add(
    input { name="p1", baseType="NUMBER", description="The first addend of the 
    operation" },
    input { name="p2", baseType="NUMBER", description="The second addend of the operation" },
    output { baseType="NUMBER", description="The sum of the two parameters" },
    description { "Add two numbers" }
)

调用只有一个参数(表或字符串)的函数时,可以省略括号。从:

所有参数表达式都在调用之前求值。形式为
f{fields}
的调用是
f({fields})
的语法糖;也就是说,参数列表是一个新表。形式为
f'string'
(或
f“string”
f[[string]])
的调用是
f('string')
的语法糖;也就是说,参数列表是单个文本字符串

这意味着以下函数调用有效:

somefunction({1,2,3,4})
somefunction{1,2,3,4}
或者,使用字符串:

print('hello!')
print 'hello!'

如果您提供一个指向文档(甚至是应用程序名称)的链接,将会有所帮助,但是:

serviceDefinitions.Add(
    input {
        name="p1",
        baseType="NUMBER",
        description="The first addend of the operation"
    },
    input {
        name="p2",
        baseType="NUMBER",
        description="The second addend of the operation"
    },
    output {
        baseType="NUMBER",
        description="The sum of the two parameters"
    },
    description {
        "Add two numbers"
    }
)
基本上调用
serviceDefinitions
table/class/struct/object的
Add
函数,并向其传递4个参数。由于在lua中,在某些情况下可以调用函数,而无需将其参数括在括号内,因此调用
输入
输出
描述
函数时使用表作为其参数


然后,每个调用的结果都被用作
Add
函数的参数。

这看起来像是服务的验证或文档?我们无法使用您提供的代码,是否有额外的上下文?