table构造代码格式化

table construction code formatting

table 人群最流行的代码格式是

mytable = {
  key1 = value1,
  key2 = element2,
  key3 = GetValue3()
  key4 = this_is_the_fourth,
  key5 = and5,
  }

但我认为以下更好:

mytable = 
  { key1 = value1
  , key2 = element2
  , key3 = GetValue3()
    key4 = this_is_the_fourth
  , key5 = and5
  }

imo 的好处是使用前者您可以轻松发现遗漏的逗号。我明确地做了这个例子来说明这一点。你发现了吗?

this guide 关于如何构造 tables,但没有像 python 的 PEP。

像这样构建 table 有什么缺点吗?

从编译器的角度来看,none:多余的空格被简单地折叠了。

不过,其他开发人员可能会在精神上窒息一秒钟。