package

C

Carl Forsman

Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");
 
D

David Mark

Carl said:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");

No, that's clearly garbage. They are using some ill-advised library.
 
D

David Mark

Carl said:
Carl said:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");
No, that's clearly garbage. They are using some ill-advised library.

Is javascript has many variations?

Not really.
all Javascript variations have different syntax?

No, it is just an example of a bad API written in JS. See also
Prototype, jQuery, Dojo, MooTools, etc.
 
C

Carl Forsman

Carl said:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");

No, that's clearly garbage. They are using some ill-advised library.

Is javascript has many variations?

all Javascript variations have different syntax?
 
C

Carl Forsman

Carl said:
Carl Forsman wrote:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");
No, that's clearly garbage. They are using some ill-advised library.

Is javascript has many variations?

Not really.
all Javascript variations have different syntax?

No, it is just an example of a bad API written in JS. See also
Prototype, jQuery, Dojo, MooTools, etc.

are you meaning this is still valid java script syntax? just it's
written in a strange way?
 
D

David Mark

Carl said:
Carl said:
On Mon, 17 May 2010 23:41:38 -0400, David Mark

Carl Forsman wrote:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");
No, that's clearly garbage. They are using some ill-advised library.
Is javascript has many variations?
Not really.
all Javascript variations have different syntax?
No, it is just an example of a bad API written in JS. See also
Prototype, jQuery, Dojo, MooTools, etc.

are you meaning this is still valid java script syntax? just it's
written in a strange way?

Sort of. Identifiers aren't supposed to use the $ character unless they
are machine-generated. In most cases, _invalid_ syntax results in a
parse error (but not always).
 
C

Carl Forsman

Carl said:
Carl Forsman wrote:
On Mon, 17 May 2010 23:41:38 -0400, David Mark

Carl Forsman wrote:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");
No, that's clearly garbage. They are using some ill-advised library.
Is javascript has many variations?
Not really.

all Javascript variations have different syntax?
No, it is just an example of a bad API written in JS. See also
Prototype, jQuery, Dojo, MooTools, etc.

are you meaning this is still valid java script syntax? just it's
written in a strange way?

Sort of. Identifiers aren't supposed to use the $ character unless they
are machine-generated. In most cases, _invalid_ syntax results in a
parse error (but not always).

You can define a package by using

$package("gamespot");

// some code

$package("");

how does it works? should I use the following instead?
package gamespot
 
C

Carl Forsman

Carl said:
Carl Forsman wrote:
On Mon, 17 May 2010 23:41:38 -0400, David Mark

Carl Forsman wrote:
Is the following standard javascript syntax? I don't seem to see it
define package and class this way in my textbook


$package("gamespot");

$class("NewsDB", {

singleton : $static(null),

url : $static("aaa.com"),

channelGuide : $static(["home", "games", "reviews", "news",
"video"]),
infoGuide : $static(["article", "review"]),

platforms : $static({"All":null, "PC":"pc", "XBOX 360": "xbox360",
"Wii": "wii", "PS3" : "ps3", "PSP" : "psp", "DS" : "ds"}),

numberToStore : $static(15),

$constructor : function() {

}

// some functions

gamespot.NewsDB.initialize();

$package("");
No, that's clearly garbage. They are using some ill-advised library.
Is javascript has many variations?
Not really.

all Javascript variations have different syntax?
No, it is just an example of a bad API written in JS. See also
Prototype, jQuery, Dojo, MooTools, etc.

are you meaning this is still valid java script syntax? just it's
written in a strange way?

Sort of. Identifiers aren't supposed to use the $ character unless they
are machine-generated. In most cases, _invalid_ syntax results in a
parse error (but not always).

Is the following is a way to define variable in javascript?

singleton : $static(null),

url : $static("aaa.com"),

numberToStore : $static(15),

it's same as define static variable like follows:

static var singleton = null;
static var url = "aaa.com";
static numberToStore = 15;
 
G

Garrett Smith

David said:
[...]
are you meaning this is still valid java script syntax? just it's
written in a strange way?

The libraries mentioned contain abstractions related to scripting web
pages.

What you posted appears to be standard fare of function calls, array
literals, object literals. The user-defined functions that are called
are not included in your post. Without seeing them, an informed
explanation of what they do cannot be provided.

I suggest learning the language, starting with the name, which is not
java scrip but javascript or, to use the correct, formal, standard name
of the language: ECMAScript.

The FAQ is long and the resources listed in it are manyWork on a little
at a time. It probably cannot be read all in one sitting.

Sort of. Identifiers aren't supposed to use the $ character unless they
are machine-generated. In most cases, _invalid_ syntax results in a
parse error (but not always).
</del>

<ins>
The dollar sign ($) and the underscore (_) are permitted anywhere in an
IdentifierName.
</ins>
 
D

David Mark

Garrett said:
David said:
Carl said:
On Mon, 17 May 2010 23:57:41 -0400, David Mark

Carl Forsman wrote:
On Mon, 17 May 2010 23:41:38 -0400, David Mark

Carl Forsman wrote:
[...]
are you meaning this is still valid java script syntax? just it's
written in a strange way?

The libraries mentioned contain abstractions related to scripting web
pages.

What you posted appears to be standard fare of function calls, array
literals, object literals. The user-defined functions that are called
are not included in your post. Without seeing them, an informed
explanation of what they do cannot be provided.

I suggest learning the language, starting with the name, which is not
java scrip but javascript or, to use the correct, formal, standard name
of the language: ECMAScript.

The FAQ is long and the resources listed in it are manyWork on a little
at a time. It probably cannot be read all in one sitting.

Sort of. Identifiers aren't supposed to use the $ character unless they
are machine-generated. In most cases, _invalid_ syntax results in a
parse error (but not always).
</del>

<ins>
The dollar sign ($) and the underscore (_) are permitted anywhere in an
IdentifierName.
</ins>

What are you talking about? You know what the specs say about $. How
many times have we discussed this? And who said anything about underscore?

Also, why did you <del> the bit about invalid syntax?
 
G

Garrett Smith

David said:
Garrett said:
David said:
Carl Forsman wrote:
On Mon, 17 May 2010 23:57:41 -0400, David Mark

Carl Forsman wrote:
On Mon, 17 May 2010 23:41:38 -0400, David Mark

Carl Forsman wrote: [...]

[...]
</del>

<ins>
The dollar sign ($) and the underscore (_) are permitted anywhere in an
IdentifierName.
</ins>

What are you talking about? You know what the specs say about $. How
many times have we discussed this? And who said anything about underscore?

Also, why did you <del> the bit about invalid syntax?

Uh-oh. I over <del>'d didn't I?

But yes, I know what the specs say about `$`. Is ECMAScript Edition 5
not quoted verbatim within <ins>?
 
T

Thomas 'PointedEars' Lahn

Garrett said:
Uh-oh. I over <del>'d didn't I?

But yes, I know what the specs say about `$`. Is ECMAScript Edition 5
not quoted verbatim within <ins>?

It is, but that is beside the point. The characters have been allowed there
before. That does not change the fact that user-defined property names
starting with `$' are considered unwise.

Learn to quote.


PointedEars
 
J

Jeremy J Starcher

That does not change the fact that user-defined property
names starting with `$' are considered unwise.

Has there ever been a case of mechanically generated code where
properties /do/ begin with a $?

Or is there another reason, besides Ecma 262 R3 Section 7.6, that makes
beginning with a $ unwise?
 
T

Thomas 'PointedEars' Lahn

Jeremy said:
Has there ever been a case of mechanically generated code where
properties /do/ begin with a $?

Or is there another reason, besides Ecma 262 R3 Section 7.6, that makes
beginning with a $ unwise?

Yes.


PointedEars
 
G

Garrett Smith

Thomas said:
[...]
But yes, I know what the specs say about `$`. Is ECMAScript Edition 5
not quoted verbatim within <ins>?

It is, but that is beside the point. The characters have been allowed there
before. That does not change the fact that user-defined property names
starting with `$' are considered unwise.

David wrote:

| Identifiers aren't supposed to use the $ character unless the are
| machine-generated.

That is the argument at hand and it is not supported by ECMAScript
Edition 5, the most recent edition of the language.

If you meant to argue that the identifier `$` is not meaningful, then
that is true, but it does not support the claim that Identifiers are not
supposed to use the character `$` unless they are machine-generated --
which is the argument at hand (try not to miss the point).
 
T

Thomas 'PointedEars' Lahn

Garrett said:
David wrote:

| Identifiers aren't supposed to use the $ character unless the are
| machine-generated.

That is the argument at hand and it is not supported by ECMAScript
Edition 5, the most recent edition of the language.

It is supported by ES3 and common sense, though.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Stefan said:
WHAT are the reasons, besides Ecma 262 R3 Section 7.6, that
make beginning identifiers with a $ unwise?

The `$' character has special meaning in several contexts already. Using it
within identifiers, too, makes code harder to maintain. (I am sure that
especially you can appreciate that.)

Also note that I answered "Yes" to an or-question.


PointedEars
 
G

Garrett Smith

Stefan said:
Very well, I'll play it your way. Let me reformulate the question, maybe
then we'll get a more informative reply than "yes" or "no" out of you:

WHAT are the reasons, besides Ecma 262 R3 Section 7.6, that
make beginning identifiers with a $ unwise?

An identifier is neither wise nor unwise. It is a Token, nothing more,
nothing less.

What meaning does `$` have, to the reader of the code? Does it do
something to determine what a string ends with? Is it an alias for
getElementById? Does it perform a CSS Query?

Or does it mean "let me go get the documentation"?

Code that explains itself is called "self-documenting code".
Self-documenting avoids failures with code comments requires no
maintenance of documentation (sounds redundant, I know).

A method Identifier that does not described what that method does
represents a failure of the code to express itself. It is not
self-documenting. This failure is commonly seen where an Identifier
represents a method that is so complicated that it cannot reasonably be
described in an Identifier.

This is a bigger problem because renaming the identifier to something
meaningful is not an option.

The `$` method does not have a clearly defined meaning as to what it
actually does. What `$` actually does in jQuery and Prototype.js cannot
be reasonably described in an identifier. It is an example of code that
fails to be meaningful and fails to do one thing. It is a symptom of bad
design.

The OP in this threa does not know what `$` is and cannot even begin to
guess what it might mean. For a beginner, it might be mistaken for a
built-in method or for some sort of magic. It is neither.

Why am I still explaining why `$` not a meaningful Identifier? That
should obvious, and moreso today than it was two years ago when I
published that in my Prototype.js review.

It is past time to stamp out the god damned dollar function.
 
D

David Mark

Garrett said:
David said:
Garrett said:
David Mark wrote:
Carl Forsman wrote:
On Mon, 17 May 2010 23:57:41 -0400, David Mark

Carl Forsman wrote:
On Mon, 17 May 2010 23:41:38 -0400, David Mark

Carl Forsman wrote:
[...]
[...]
<del>
Sort of. Identifiers aren't supposed to use the $ character unless
they
are machine-generated. In most cases, _invalid_ syntax results in a
parse error (but not always).
</del>

<ins>
The dollar sign ($) and the underscore (_) are permitted anywhere in an
IdentifierName.
</ins>

What are you talking about? You know what the specs say about $. How
many times have we discussed this? And who said anything about
underscore?

Also, why did you <del> the bit about invalid syntax?

Uh-oh. I over <del>'d didn't I?

But yes, I know what the specs say about `$`. Is ECMAScript Edition 5
not quoted verbatim within <ins>?

Why do you cite irrelevant documents (e.g. HTML5, DOM3, etc.) These
things aren't in widespread use yet, so who cares what they say at this
point?
 

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,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top