Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2018 04:55:08 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r330012 - head/share/man/man9
Message-ID:  <201802260455.w1Q4t8tO072387@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Feb 26 04:55:08 2018
New Revision: 330012
URL: https://svnweb.freebsd.org/changeset/base/330012

Log:
  style.lua(9): Add some additional notes about naming and commas
  
  camelCase tends to be preferred for function identifiers, while
  internal_underscores are preferred for variable identifiers. This convention
  makes it a little bit easier to eyeball whether variable/function usage is
  correct.
  
  The optional commas for final table values are preferred to reduce chances
  for error.

Modified:
  head/share/man/man9/style.lua.9

Modified: head/share/man/man9/style.lua.9
==============================================================================
--- head/share/man/man9/style.lua.9	Mon Feb 26 04:33:05 2018	(r330011)
+++ head/share/man/man9/style.lua.9	Mon Feb 26 04:55:08 2018	(r330012)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 20, 2018
+.Dd February 25, 2018
 .Dt STYLE.LUA 9
 .Os
 .Sh NAME
@@ -83,6 +83,30 @@ Single-line conditional statements and loops should be
 .Pp
 .Ic local
 variables should be preferred to global variables in module scope.
+internal_underscores tend to be preferred for variable identifiers, while
+camelCase tends to be preferred for function identifiers.
+.Pp
+If a table definition spans multiple lines, then the final value in the table
+should include the optional terminating comma.
+For example:
+.Bd -literal
+-- No terminating comma needed for trivial table definitions
+local trivial_table = {1, 2, 3, 4}
+
+local complex_table = {
+	{
+		id = "foo",
+		func = foo_function, -- Trailing comma preferred
+	},
+	{
+		id = "bar",
+		func = bar_function,
+	},	-- Trailing comma preferred
+}
+.Ed
+.Pp
+This reduces the chance for errors to be introduced when modifying more complex
+tables.
 .Pp
 Multiple local variables should not be declared
 .Sy and



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802260455.w1Q4t8tO072387>