ECMAScript syntax

J

Joe Kelsey

Does the "semicolon insertion" really affect you if you format code as

function x (y)
{
// ...
}

instead of:

function x (y) {
// ...
}

The jslint page complains about lines ending in ) due to the nebulous
idea of "semicolon insertion". I have not reviewed the ECMAScript pdf
in great detail to try to pin this pretty-printing issue down. In
general, I find that code formatted in the "K&R" style (opening brace
on same line as if, while, function) confusing and difficult to read
compared with placing curly braces on separate lines.

On another subject, the difference between inner functions defined
explicitly versus defined using function expressions seems like a good
one for a FAQ. Under what circumstances does it make a real
difference whether you use function expression versus function
statement versus Function object?

/Joe
 
D

Douglas Crockford

Does the "semicolon insertion" really affect you if you format code as
function x (y)
{
// ...
}

instead of:

function x (y) {
// ...
}

The jslint page complains about lines ending in ) due to the nebulous
idea of "semicolon insertion". I have not reviewed the ECMAScript pdf
in great detail to try to pin this pretty-printing issue down. In
general, I find that code formatted in the "K&R" style (opening brace
on same line as if, while, function) confusing and difficult to read
compared with placing curly braces on separate lines.

I like to avoid insecurities in languages. I prefer to work where the ice is
thickest. Since I am the one who wrote jslint, that's what it likes, too. But it
has a checkbox that you can clear that turns off that check.

Legibility is of paramount importance. If you find the K&R convention difficult
to read, then don't use it. One of the deficiencies of the C family is that
there is no ideal way to make them pretty. I think that should be an important
consideration in the design of syntax, but clearly I am not with the mainstream
on this.

http://www.crockford.com/javascript/lint.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top