Now that I'm *finally* digging into these scripts, I've noticed that there isn't a lot of standardization across scripts with regard to capitalization. I want to propose the following style for scripts (keep in mind this won't be enforced by the language, just a common practice).
Module names: Camel cased, no underscores (all uppercase for abbreviations)
Examples: FTP, SSH, Notice, Remote, Signatures
Enum values: Upper-case with underscores
Examples: KNOWN_HOSTS, SSH, NFS3_REG
Variables: Lower-case with underscores
Examples: example_variable, ftp_sessions
This should follow the established conventions of most scripts (unfortunately not all). Did I leave anything out?
The enum values doesn't quite work because Notice enum values have been defined as Camel-cased with underscores mostly. I'm sort of inclined to leave this as it is because it pinpoints when a notice type is being defined. I suppose that would be a subcategory of enum values that is just done specially.
What do you recommend as the standard for function names? I'm seeing them named like variables (lower_case_with_underscores). Personally, I'd prefer that they differ in some way from variables. How about camelCase with the first character lower case (to distinguish them from types)?
And I don't know how often we need to name new events. Right now, their naming appears to also follow that of variables, lower_case_with_underscores. I assume this won't change, since there are lots and lots of events already defined, but I figured I should ask, for completeness.
Personally, I'd prefer that they differ in some way from variables. How
about camelCase with the first character lower case (to distinguish them
from types)?
I appreciate the point you're making, but I resist this change. It would
require extensive alterations (pretty much all event names, for starters)
and result in a style that to my eye would be jarring, given how used I am
to the current style.
Sorry, that paragraph is meant to refer to script functions, not to events. I concede that it would not be a good idea to change the naming convention for events.
Sorry, that paragraph is meant to refer to script functions
Understood.
not to events
The problem here is that script functions and event handlers are nearly
isomorphic in the language, with the only difference being that functions
optionally return values. So a change to just script functions would then
look peculiar in that most "functions" (really handlers) don't reflect the
change.
Some might argue that that's a feature, not a bug. If the change were
indeed confined to script functions, it would limit its impact / jarring-ness,
and maybe I could be talked into it if others are enthused too.
I agree with Gregor and Vern. Changing the style for event and function names in the shipped scripts would be a big change (mentally and code-wise).
Taking Vern's point one step further about functions and events being isomorphic; functions and events are still just variables so keeping them with the same style as variables actually makes a lot of sense. That's actually why I didn't specify functions and events originally. I should have point that out though. Try printing a function sometime if you want to see what I mean.