[Swift-devel] Standard library

Mihael Hategan hategan at mcs.anl.gov
Sat Jan 10 22:02:16 CST 2015


On Sat, 2015-01-10 at 16:57 -0600, Tim Armstrong wrote:
> I agree, I don't care about the naming convention for functions, so let's
> just pick one and be consistent going forward (we can keep old names
> around, at least forsome amount of time).

Let's briefly discuss this and put it to a vote.

I prefer camel case because it helps with tokenization in my head. In
other words when I read a program, I would like a variable or function
name to be a single entity visually. Underscores are very close to a
blank, so it's easy to confuse the two on a quick visual scan and
interpret, say function_name, as two separate tokens instead of one.

Other than that, complex tokens themselves are probably easier to read
with underscores: long_name_of_variable_that_holds_value vs
longNameOfVariableThatHoldsValue. 

See http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.158.9499 and
http://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf for some relevant research. Unfortunately they focus not on program readability, but on identifier readability.

Mihael




More information about the Swift-devel mailing list