Browse Source

Add Naming section with naming and namespacing

Alois Mahdal 5 years ago
parent
commit
6470d1563b
1 changed files with 32 additions and 0 deletions
  1. 32
    0
      notes/style.md

+ 32
- 0
notes/style.md View File

@@ -270,6 +270,38 @@ possible inherited variables right in the short description, using
270 270
 naive Bash notation (no quoting) as in above example.
271 271
 
272 272
 
273
+Naming
274
+------
275
+
276
+### Module name and namespacing ###
277
+
278
+A valid Shellfu module name consists of lowercase letters, numbers and
279
+underscore, ie. `[a-z_][a-z0-9_]`.  This name must be used as name of
280
+the module file, without the extension.
281
+
282
+Module must not define a global variable or function that does not start
283
+with its name.  That is, a global variable or function may be:
284
+
285
+ *  Just module name itself.
286
+
287
+ *  Module name itself followed by *two underscores** (`__`) and
288
+    an id consisting of one or more letters, numbers or underscores.
289
+
290
+ *  Any of above, prefixed by one or more underscores.
291
+
292
+
293
+### Private names ###
294
+
295
+Names starting with **double underscore** are considered strongly private:
296
+that is, they must only be used in the same file.
297
+
298
+Names starting with **single underscore** are considered weakly private: they
299
+may be used in other modules within the same project.  (This can be useful
300
+in plugin scenarios.)
301
+
302
+When in doubt, use **double underscore**.
303
+
304
+
273 305
 Common language constructs
274 306
 --------------------------
275 307