I'm definitely leaning towards pure lowercase. It's not really more work to write, and it's a lot easier to read afterwards. Plus it's really consistent with the standard library, among others.
>>1
Either is fine as long as it's consistent. I tend to use CamelCase, but K&R style is fine too. My favorite style is lowercase and a minus sign, like most-positive-fixnum, but I've never seen any language except Lisps use that, mostly because their syntax wouldn't support it (infix notation).
Name:
Anonymous2010-04-09 4:39
I prefer CamelCase for variables and the first style(i forgot what it was called) for functions.
Name:
Anonymous2010-04-09 4:51
>>3
Interesting, that's pretty much the opposite of Google style. They use CamelCase for all types, functions and methods, and use lower_case for all variables. (They also forbid the use of shitCase.) Unless you meant CamelCase for types and not variables, in which case your style isn't all that uncommon (it's just ugly.)
Also, what is /prog/'s opinion on the trailing _t? It seems redundant if you properly prefix all your global identifiers, i.e. ns_foo where ns is the acronym for whatever namespace you want. Thoughts?
Typedef Names
Capitalized, with no _t suffix or other cutesy thing to say ``I'm a type'' - we can see that from it's position in the declaration! (Besides, all names ending with _t are reserved by Posix.) The capitalization is needed to distinguish type names from variable names - often both want to use the same application-level word.
>>11 [JEWS@JEWS ~]$ ghci
GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> let my-totally-awesome-square-function = \x -> x * x
<interactive>:1:4: Parse error in pattern
Prelude> let haskellCaseIsShit = \x -> x * x
Prelude> haskellCaseIsShit 9
81
Prelude>
Name:
Anonymous2010-04-09 13:31
I use lowercase for functions and variables, no underscores except as a namespace delimiter (e.g. ns_getcbfl(), not ns_get_cb_fl()), and all uppercase for #defines. Global variables, which tend to be rather important, start with an uppercase letter.
[JEWS@JEWS ~]$ ghci
GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> let my-totally-awesome-square-function = \x -> x * x
* Exception: Stack Overflow
Name:
Anonymous2010-04-09 13:43
>>9
Yeah um, just because Go is sponsored by Google doesn't mean they actively use it. It's just an experiment right now. Here's Google's real style guide:
Also, doesn't anyone else think that assigning semantic meaning to identifier name style is, well, dumb? I have the same problem with Python's "private" variables by leading with underscores...
Also, doesn't anyone else think that assigning semantic meaning to identifier name style is, well, dumb? I have the same problem with Python's "private" variables by leading with underscores...
It does make it more of a pain to change the visibility of something, but I'm not inherently against it. Enforced conventions are fine when you would be following them anyway, and a pain when the convention is stupid.
Name:
Anonymous2010-04-09 14:24
>>18
Leading underscores is different to changingTheCaseStyle. Clearly anything beginning with __ isn't going to be used in everyday code. But yes, Python's version of int main() is idiotic.