xxx行的函数具有超过60个上值 [英] function at line xxx has more than 60 upvalues

查看:150
本文介绍了xxx行的函数具有超过60个上值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些如下的lua代码:

I have written some lua code like this:

local a1 = 1
local a2 = 2
local a3 = 3
local a4 = 3
local a5 = 3
local a6 = 3
local a7 = 3
local a8 = 3
local a9 = 3
local a10 = 3

local a11 = 3
local a12 = 3
local a13 = 3
local a14 = 3
local a15 = 3
local a16 = 3
local a17 = 3
local a18 = 3
local a19 = 3
local a20 = 3

local a21 = 3
local a22 = 3
local a23 = 3
local a24 = 3
local a25 = 3
local a26 = 3
local a27 = 3
local a28 = 3
local a29 = 3
local a30 = 3

local a31 = 1
local a32 = 2
local a33 = 3
local a34 = 3
local a35 = 3
local a36 = 3
local a37 = 3
local a38 = 3
local a39 = 3

local a40 = 3
local a41 = 3
local a42 = 3
local a43 = 3
local a44 = 3
local a45 = 3
local a46 = 3
local a47 = 3
local a48 = 3
local a49 = 3
local a50 = 3

local a61 = 3
local a62 = 3
local a63 = 3
local a64 = 3
local a65 = 3
local a66 = 3
local a67 = 3
local a68 = 3
local a69 = 3
local a70 = 3

local function fun1(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)
    print('.......')
end

local function fun2()
    fun1(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
    fun1(a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
    fun1(a21, a22, a23, a24, a25, a26, a27, a28, a29, a30)
    fun1(a31, a32, a33, a34, a35, a36, a37, a38, a39, a40)
    fun1(a41, a42, a43, a44, a45, a46, a47, a48, a49, a50)
    fun1(a51, a52, a53, a54, a55, a56, a57, a58, a59, a60)
    fun1(a61, a62, a63, a64, a65, a66, a67, a68, a69, a70)
end

当运行以下代码时,我得到了这样的错误:

and i got an error like this when ran this code:

    78: function at line 71 has more than 60 upvalues

我知道这种代码很丑陋,我可以使用其他方式(例如表)来做,但是这种代码可能是由我的用户编写的.

i know this kind of code is ugly and i can use some way else to do it (like table), but this kind of code may be written by my users.

有人可以帮我解释一下,并告诉我如何避免这种情况吗?非常感谢.

can someone explain this for me, and tell me how to avoid this? thanks very much.

推荐答案

告诉我如何避免这种情况?

tell me how to avoid this?

有个老笑话.一个人走进医生办公室,说:当我这样举起手臂时,会很痛."医生说:所以不要像这样举起你的手臂."

There's the old joke. A guy walks into a doctor's office and says, "It hurts when I raise my arm like this." The doctor says, "So don't raise your arm like that."

如果您的用户编写的Lua代码无法编译,则无法解决.像这样的东西,这不仅仅意味着非法的编译错误:

If your users write Lua code that does not compile, that's not something you can fix. This is no more illegitimate a compile error than something like:

if condition  --forgot the then
  return something
end

因此,如果您的代码要接受任意Lua脚本进行编译和执行,则需要才能处理未编译的Lua脚本.由于任何原因.

So if your code is going to accept arbitrary Lua scripts to compile and execute, it will need to be able to deal with Lua scripts that don't compile. For whatever reason.

如果编译失败,请向用户报告错误,并尽力而为.

If compilation fails, report the error to the user and recover the best you can.

这篇关于xxx行的函数具有超过60个上值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆