[OpenLayers-Dev] Dev Digest, Vol 11, Issue 28

lszklanny at where2getit.com lszklanny at where2getit.com
Fri Aug 31 12:46:04 EDT 2007


> Send Dev mailing list submissions to
> 	dev at openlayers.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://openlayers.org/mailman/listinfo/dev
> or, via email, send a message with subject or body 'help' to
> 	dev-request at openlayers.org
>
> You can reach the person managing the list at
> 	dev-owner at openlayers.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Dev digest..."
>
>
> Today's Topics:
>
>   1. Semicolons (Erik Uzureau)
>   2. Re: Semicolons (Jeff Dege)
>   3. Re: Semicolons (Paul Spencer)
>   4. Re: Semicolons (Erik Uzureau)
>   5. Re: Semicolons (John Cole)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 31 Aug 2007 16:25:56 +0200
> From: "Erik Uzureau" <erik.uzureau at metacarta.com>
> Subject: [OpenLayers-Dev] Semicolons
> To: "dev at openlayers" <dev at openlayers.org>
> Message-ID:
> 	<6ae3fb590708310725m7e93433bj79cbf4550cde1e61 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> 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
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 31 Aug 2007 09:30:32 -0500
> From: "Jeff Dege" <jdege at korterra.com>
> Subject: Re: [OpenLayers-Dev] Semicolons
> To: "Erik Uzureau" <erik.uzureau at metacarta.com>,	"dev at openlayers"
> 	<dev at openlayers.org>
> Message-ID:
> 	<34E056CD4D475841B8C9ABCE956F92F6370B15 at mrburns.KorOffice.local>
> Content-Type: text/plain;	charset="us-ascii"
>
>> On Friday, August 31, 2007 9:26 AM, Erik Uzureau wrote:
>> To: dev at openlayers
>>
>> 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.
>
> In the languages I cut my teeth on, this is a function declaration:
>
> function foo() {}
>
> And this is an assignment statement with an inline function for the
> rhs:
>
> var foo = function() {};
>
> And I'm used to semicolon terminators for assignment statements, but
> not for function declarations.
>
> The most important question, though, is what does the language standard
>  say?
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 31 Aug 2007 10:34:26 -0400
> From: Paul Spencer <pspencer at dmsolutions.ca>
> Subject: Re: [OpenLayers-Dev] Semicolons
> To: "Erik Uzureau" <erik.uzureau at metacarta.com>
> Cc: "dev at openlayers" <dev at openlayers.org>
> Message-ID: <EB23FA0D-B690-4645-864F-A7132B0D3097 at dmsolutions.ca>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> 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/ |
> +-----------------------------------------------------------------+
>
>
>
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 31 Aug 2007 16:50:59 +0200
> From: "Erik Uzureau" <erik.uzureau at metacarta.com>
> Subject: Re: [OpenLayers-Dev] Semicolons
> To: "Paul Spencer" <pspencer at dmsolutions.ca>
> Cc: "dev at openlayers" <dev at openlayers.org>
> Message-ID:
> 	<6ae3fb590708310750y58025743s152a161e11f6b5ad at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Excellent!
>
> Thanks Paul and Jeff for your quick and insightful responses. I agree
> with this approach and will go back and remove those extra ;'s I've
> just added. :-)
>
> Erik
>
> On 8/31/07, Paul Spencer <pspencer at dmsolutions.ca> wrote:
>> 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/ |
>> +-----------------------------------------------------------------+
>>
>>
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 31 Aug 2007 10:18:40 -0500
> From: John Cole <john.cole at uai.com>
> Subject: Re: [OpenLayers-Dev] Semicolons
> To: 'Erik Uzureau' <erik.uzureau at metacarta.com>, Paul Spencer
> 	<pspencer at dmsolutions.ca>
> Cc: "dev at openlayers" <dev at openlayers.org>
> Message-ID: <76758090F8686C47A44B6FF52514A1D307909E44 at hermes.uai.int>
> Content-Type: text/plain;	charset="windows-1250"
>
> To add a different opinion, I always use the semicolons.  Why?  To
> avoid side effects and avoid ambiguity.  With large projects, we have
> run into the situation where a dangling line creates syntactically
> legal, but logically wrong code.  And it can be confusing trying to
> understand why removing (or adding) a blank line can change how a
> program operates.
>
>>From the O'reilly JS book:
>
> return
> true
>
> Is interpreted as
>
> return;
> true;
>
> When you really meant "return true;"
>
> You can also find weird assignments when someone doesn?t remove a '+'
> at the end of a concatenation that would be easier to see if the ';'
> were always at the end of the line.
>
> Remember, JS is actually putting the ';' in, it's just trying to figure
> out where they go.  It's not that they are not needed; it's a matter of
> who puts them in.
>
> "Omitting semicolons is not a good programming practice; you should get
> in the habit of using them." --JavaScript, The Definitive Guide,
> O'Reilly, 4th Edition
>
> John
>
>
>
> -----Original Message-----
> From: dev-bounces at openlayers.org [mailto:dev-bounces at openlayers.org] On
> Behalf Of Erik Uzureau
> Sent: Friday, August 31, 2007 9:51 AM
> To: Paul Spencer
> Cc: dev at openlayers
> Subject: Re: [OpenLayers-Dev] Semicolons
>
> Excellent!
>
> Thanks Paul and Jeff for your quick and insightful responses. I agree
> with this approach and will go back and remove those extra ;'s I've
> just added. :-)
>
> Erik
>
> On 8/31/07, Paul Spencer <pspencer at dmsolutions.ca> wrote:
>> 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/ |
>> +-----------------------------------------------------------------+
>>
>>
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.484 / Virus Database: 269.13.1/981 - Release Date:
> 8/31/2007 6:13 AM
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.484 / Virus Database: 269.13.1/981 - Release Date:
> 8/31/2007 6:13 AM
>
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the sender. This message contains confidential information and is
> intended only for the individual named. If you are not the named
> addressee you should not disseminate, distribute or copy this e-mail.
>
>
> ------------------------------
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
>
> End of Dev Digest, Vol 11, Issue 28
> ***********************************

I'd like to point that some compressors are very sensitive to missing
semicolons separating statements, e.g. Dean Edward's Packer.
Les






More information about the Dev mailing list