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
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to