[OpenLayers-Dev] Semicolons

Paul Spencer pspencer at dmsolutions.ca
Fri Aug 31 10:34:26 EDT 2007


Erik,

I am in favour of a coding style that is syntatically (?) correct  
while requiring the minimum amount of typing.

I believe that using this style:

var foo = function() {};

does require the semi-colon at the end of the statement while:

function foo() {}

doesn't.  I have tested this with jslint and it reports a warning if  
the semi-colon is missing in the first case and not in the second  
case.  An extra semi-colon does not cause a syntax warning either.

As you know, javascript allows some laxity with semi-colons and the  
only time it really bites you is when you want to compress stuff, so  
I'm not really strongly opinionated if this is for test cases that  
are unlikely to be compressed.  However, as a matter of habit, I  
believe that we should use semi-colons in the first style of coding  
and not in the second because the encourages an understanding of why  
the semi-colons are required (or not) which means we will understand  
the language a little better.

Cheers

Paul


On 31-Aug-07, at 10:25 AM, Erik Uzureau wrote:

> In a bout of friday afternoon lunacy, I began adding semicolons to the
> end of the function declarations in the tests files.
>
> The original impetus for this was that I noticed that doing so reduced
> the number of errors reported by the JSEclipse plugin that I use for
> my JS development work. Certainly neither an urgent nor universal
> change, but I need to spin some brain cycles.
>
> Someone else has brought it to my attention that s/he is *not* in
> favor of that style....
>
> I prefer:
>
> function foo() {};
> and
> var foo = function() {};
>
> whereas s/he prefers:
>
> function foo() {}
> and
> var foo = function() {}
>
>
>
> do others have an opinion on this? the OC in me wants everything to be
> the same in our code, and I'm more than willing to rollback the
> changes I've just done if people are in favour of the other way of
> doing it.
>
> Please cast a vote if you have some thoughts.
>
> Erik
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+








More information about the Dev mailing list