Declarations (esp. of Globals)

G

Gene Wirchenko

Dear JavaScripters:

There is nothing quite like checking out someone else's code. "He
is doing it all wrong!" is a thought that can all-too-easily come to
mind or mouth.

It is a bit awkward when looking at an identifier. Is this thing
declared in this function/scope? Is it a global? Is it something
DOMy?

I am a stickler for declarations and prefer to declare
everything. As applied to JavaScript, what say you? And why?

Sincerely,

Gene Wirchenko
 
M

Mike Duffy

I am a stickler for declarations and prefer to declare
everything. As applied to JavaScript, what say you? And why?

I agree 100%. In the case of Javascript, even more so.

My coding philosophy is a bit different than most of the people here. I am
a firm believer in learning "barely" enough. This gives me the time to
learn barely enough about a much wider range of subjects than I could if I
decided to become an expert at anything.

Thus please don't take my advice too seriously. If you want a good laugh,
just take a look at my js libraries on my web-site. Yessir! I wrote my own.
I would advertise them here if not for the fact that they are 100% perfect
for my utilization and about 0% for everyone else.
 
T

Thomas 'PointedEars' Lahn

Mike said:
I agree 100%. In the case of Javascript, even more so.

There is no "Javascript" [1].

However, in ECMAScript implementations like JavaScript, JScript, etc.,
variable declarations are important:

If you do not declare an identifier a variable, and assign to it, one of
three things can happen: nothing (no effect at all, because an existing
property was read-only), an exception is thrown (because an existing
property could not be overwritten or created), or a property of the global
object is being created or overwritten (sometimes called an "implied
global").

With a variable declaration, the scope of a standalone identifier is clear.

That is why in ECMAScript Edition 5.x's Strict Mode¹, such an assignment, if
the identifier cannot be resolved, always throws a ReferenceError exception.
You can attempt to trigger Strict Mode with

"use strict";

on top of the code or function body.

See also: <https://developer.mozilla.org/en/JavaScript/Strict_mode>


PointedEars
___________
¹ not to be confused with layout engines' Standards (Compliance) Mode

[1] <http://PointedEars.de/es-matrix>
 
G

Gene Wirchenko

Mike said:
I am a stickler for declarations and prefer to declare
everything. As applied to JavaScript, what say you? And why? ^^^^^^^^^^

I agree 100%. In the case of Javascript, even more so.
^^^^^^^^^^

There is no "Javascript" [1].
<snip>

It's a typing error, or is that too inconvenient for you?.

OP here. It might be inconvenient for him, but it is certainly
convenient for me.

It is things like that that help a person who is new to a
newsgroup determine who gives good advice and who should be killfiled.
Mr. Lahn quickly establish himself in the second category.

Squawking over missing a capital in "JavaScript" is rather
missing the point when done in a newsgroup called
"comp.lang.javascript".

Sincerely,

Gene Wirchenko
 
M

Mike Duffy

It is things like that that help a person who is new to a
newsgroup determine who gives good advice and who should be killfiled.
Mr. Lahn quickly establish himself in the second category.

Do not count him out too quickly. Many of the important things I have
learned here have been authored by him. Some people here take themselves
too seriously, but not anyone who calls himself "Pointed Ears". Take a good
look at what he actually says. If you are beginner, a lot of the detail he
usually goes into will probably not be interesting, but he does understand
what he is talking about.
 
S

Scott Sauyet

Gene said:
     Squawking over missing a capital in "JavaScript" is rather
missing the point when done in a newsgroup called
"comp.lang.javascript".

The point is not that the capital is missing. The point is that
unlike with Ruby, C++, Java, and many other languages, there are a
number of different implementations of ECMAScript with sometimes quite
incompatible behavior. When speaking of "Javascript", it sounds as
though one is speaking of the Mozilla implementation, "JavaScript",
but usually it turns out that it is some abstract common subset of
these implementations that is meant.

Personally, I don't have any issue with the use of "Javascript" as a
shorthand for an abstract ECMAScript implementation. If one
implementation is being described, it's usually easy enough to make
clear. For the same reason, I use "LISP" for a number of languages
which differ IMHO quite a bit more than do the popular ECMAScript
implementations. If I want to distinguish Allegro CL, I simply say
so.

Thomas Lahn often makes a point of noting this distinction, often
rather brusquely. It seems to me mostly pedantry, but it's probably
good to have pedants among us.

-- Scott
 
G

Gene Wirchenko

^
Edit: Add "ed".
Do not count him out too quickly. Many of the important things I have
learned here have been authored by him. Some people here take themselves
too seriously, but not anyone who calls himself "Pointed Ears". Take a good
look at what he actually says. If you are beginner, a lot of the detail he
usually goes into will probably not be interesting, but he does understand
what he is talking about.

Manner and manners count for a lot. Some people lord their
knowledge over others, and one has to wade through their misemotional
data. Others are more helpful.

My killfile of Mr. Lahn is only mark read, so I still have the
messages should I ever need to refer to them.

Sincerely,

Gene Wirchenko
 
M

Mike Duffy

Manner and manners count for a lot. Some people lord their
knowledge over others, and one has to wade through their misemotional
data. Others are more helpful.

My killfile of Mr. Lahn is only mark read, so I still have the
messages should I ever need to refer to them.

He is not too likely to help you out in the future now that he knows you
will not be seeing any possible responses. But if you feel that you are not
able to contenance his style, by all means you should killfile him.

I am curious though to know why you feel the need to tell him that you have
done so. Thomas has never changed his style to suit the regulars, so it is
very unlikely that he will do so for a newcomer.
 
T

Thomas 'PointedEars' Lahn

John said:
Thomas said:
Mike said:
I am a stickler for declarations and prefer to declare
everything. As applied to JavaScript, what say you? And why? ^^^^^^^^^^

I agree 100%. In the case of Javascript, even more so.
^^^^^^^^^^

There is no "Javascript" [1].
<snip>

It's a typing error, […]

Unfortunately, much too often it is evidence of a serious but common
misconception. Hence my remark.


PointedEqars
--
If you get a bunch of authors […] that state the same "best practices"
in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
 
T

Thomas 'PointedEars' Lahn

Mike said:
He is not too likely to help you out in the future now that he knows you
will not be seeing any possible responses. But if you feel that you are
not able to contenance his style, by all means you should killfile him.

I am curious though to know why you feel the need to tell him that you
have done so. Thomas has never changed his style to suit the regulars, so
it is very unlikely that he will do so for a newcomer.

I had soft-killfiled him permanently already because of his clueless
reaction, < Apparently Mr.
Wirchenko is confusing me with someone who could take a wannabe like him
seriously (mind you, _not_ *newbie*), and he is delusional enough to think
that I would *lose* something by not reading his FAQs.

(BTW, it's)

PointedEars (F'up2 poster)
 
G

Gene Wirchenko

He is not too likely to help you out in the future now that he knows you
will not be seeing any possible responses. But if you feel that you are not
able to contenance his style, by all means you should killfile him.

I am curious though to know why you feel the need to tell him that you have
done so. Thomas has never changed his style to suit the regulars, so it is
very unlikely that he will do so for a newcomer.

Maybe, the regulars have gotten used to it -- "Grin and bear it."
-- but maybe, my post will result in him reconsidering his manner.

Since his posts do not appear useful, I would rather that he not
reply to my posts. I have seen the phenomenon of a thread getting
hijacked by other discussion and the original question never being
answered.

Sincerely,

Gene Wirchenko
 
G

Gene Wirchenko

On Tue, 29 Nov 2011 13:36:49 -0800 (PST), Scott Sauyet

[snip]
Thomas Lahn often makes a point of noting this distinction, often
rather brusquely. It seems to me mostly pedantry, but it's probably
good to have pedants among us.

Yes, brusquely. I have also seen it done and the question not
answered. I can be pedantic myself. Pedants can be fine, but there
is a glut of rude pedants.

Sincerely,

Gene Wirchenko
 
S

Scott Sauyet

Gene said:
I have seen the phenomenon of a thread getting hijacked by other
discussion and the original question never being answered.

That's very common on USENET, but does seem more prevalent here. As
long as people don't mistake this discussion group for a (paid?) help
forum, we're fine. Many of the most interesting discussions start as
asides to existing threads.

-- Scott
 
J

John G Harris

The point is not that the capital is missing. The point is that
unlike with Ruby, C++, Java, and many other languages, there are a
number of different implementations of ECMAScript with sometimes quite
incompatible behavior. When speaking of "Javascript", it sounds as
though one is speaking of the Mozilla implementation, "JavaScript",
but usually it turns out that it is some abstract common subset of
these implementations that is meant.

Personally, I don't have any issue with the use of "Javascript" as a
shorthand for an abstract ECMAScript implementation. If one
implementation is being described, it's usually easy enough to make
clear. For the same reason, I use "LISP" for a number of languages
which differ IMHO quite a bit more than do the popular ECMAScript
implementations. If I want to distinguish Allegro CL, I simply say
so.

Thomas Lahn often makes a point of noting this distinction, often
rather brusquely. It seems to me mostly pedantry, but it's probably
good to have pedants among us.

It's worse than pedantry. He flatly refuses to agree that a simple name
covering all variants would be useful. (In the same way that 'vehicle'
covers cars, lorries, motorbikes, etc (1)).

He will only agree to a multi-word sentence that excludes some of the
languages that are On Topic for this news group. (Exclusion justified on
the grounds that he doesn't want to discuss them).

John


(1) Though whether something on wheels aiming to go at Mach 1.3 should
be included is debatable.
 
G

Gene Wirchenko

That's very common on USENET, but does seem more prevalent here. As
long as people don't mistake this discussion group for a (paid?) help
forum, we're fine. Many of the most interesting discussions start as
asides to existing threads.

That might well be, but I have had the situation of needing an
answer to my question, never getting anything, and yet there is a long
thread. I think that other people then tend to think that the
question has been answered.

Sincerely,

Gene Wirchenko
 
T

Tom de Neef

Gene Wirchenko said:
Since his posts do not appear useful, ...

You must have misread. There was quite some useful info right from the
start.
I suggest you focus on content rather than style.

Tom
 
S

Scott Sauyet

Gene said:
     That might well be, but I have had the situation of needing an
answer to my question, never getting anything, and yet there is a long
thread.  I think that other people then tend to think that the
question has been answered.

Again, that's very common. Feel free to restate the question, in the
same thread or another. But remember that many users are here for the
discussions and very few are here specifically to try to answer your
questions. If you make the question interesting enough, you'll
probably get a number of answers.

-- Scott
 
G

Gene Wirchenko

You must have misread. There was quite some useful info right from the
start.
I suggest you focus on content rather than style.

No, I prefer to focus on style. That way I get to know who posts
in a readable, helpful style. Of those, it is almost certain that
some will post correct information. Because their style is readable,
it is easier to determine usefulness and correctness.

Or I could try deciphering posts written by people who are
antagonistic or have axes to grind.

No, I think I will continue with the first way.

Thank you to all of you who have posted helpfully. I like your
style!

Sincerely,

Gene Wirchenko
 

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

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top