Accessing pseudo-classes through Javascript (Jscript)

D

Dr John Stockton

JRS: In article <[email protected]>, dated
Mon, 29 May 2006 18:58:49 remote, seen in
Randy Webb said:
As JRS is so fond of saying, $( is less error prone than
document.getElementById( ever will be :)

Justify that, if you can.

A local database search finds no occurrence of $( in my outgoing
mail/news since 2001-01-04 - and that one was not related to javascript.
The database contains virtually all of my outgoing messages.
 
R

Randy Webb

Dr John Stockton said the following on 5/31/2006 12:48 PM:
JRS: In article <[email protected]>, dated
Mon, 29 May 2006 18:58:49 remote, seen in

Justify that, if you can.

Be pedantic if you must.
A local database search finds no occurrence of $( in my outgoing
mail/news since 2001-01-04 - and that one was not related to javascript.
The database contains virtually all of my outgoing messages.

Let me re-phrase it in a way that you won't be pedantic about it:

JRS is fond of using 1 and 2 character function names and defending that
practice by saying that it is less error prone to typos.
 
V

VK

To OP:

The pseudo-selectors
:first-child
:first-letter
:first-line
:active
:hover
:link
:visited
are not available for scripting, at least not on IE. Potentially it is
possible to study linked stylesheets for rules and change corresponding
rules. It is /much/ easier though simply switch class name for
elements.

<OT>
"$ only for autogenerated code":- plain junk.
The whole sentence is indeed (as already pointed) taken from Java specs
where internal custom classes are stored in autogenerated files like
$Class1.class, $Class2.class etc. (when compiling the .java source). No
connection neither relevance to JavaScript.

In MS-DOS and (inheritedly) in Windows some service programs - very few
by now - start autoigenerated files with $ too. No connection neither
relevance to JavaScript.
From the other side in many programming languages $ sign is used as
variable type modifier (some old BASIC's) or simply as a marker of
variable. Say if you open any Perl program you'll be overwhelmed with
the amount of $'s because there it means any scalar thus not a function
pointer (&), object reference (*), array (@) or hash (%).

About the "weirdness" of single $ as identifier: that is exactly the
reason it was chosen. A widely used yet proprietary identifier has to
be short, memorizable and "unusual" so not lead to name conflicts - at
least not on every single step.

All this has no relevance to the quality of prototype.js as such.
</OT>
 
R

Richard Cornford

VK wrote:
"$ only for autogenerated code":- plain junk.
<snip - more nonsense>

Thank you for endorsing the position that $ should only be used as an
initial character in a machine generated identifier.
All this has no relevance to the quality of prototype.js
as such.

How would you know?

Richard.
 
V

VK

Thank you for endorsing the position that $ should only be used as an
initial character in a machine generated identifier.

Thank you for thinking of Perl programming as of a machine generated
process :)
my $foo = "bar";
has to be typed by hand, including $ sign.

About "an initial character" - in some BASIC dialects (including the
British made Sinclair BASIC btw) $ denotes string value as opposed to
numeric value and placed as the end of identifier:
let a = 1;
let a$ = "foobar";

So the semantics of $ is similar to the symbol of rose: it has so many
meanings that it has no particular meaning whatsoever.
</OT>
 
R

Richard Cornford

VK said:
Thank you for thinking of Perl programming ...
<snip>

Another demonstration of your talent for being spectacularly
irrelevant. This is a Javascript group, and we are talking about
javascript. Any special meaning that $ may have in other languages is
entirely their own business.

Richard.
 
T

Thomas 'PointedEars' Lahn

VK said:
Thank you for thinking of Perl programming as of a machine generated
process :)
my $foo = "bar";
has to be typed by hand, including $ sign.

That is exactly the point. We are not talking about identifiers in Perl,
but about identifiers in ECMAScript implementations. Yet in Perl (and
other languages used server-side), `$' is a mandatory prefix of identifiers
for scalars, and every standalone $foo is considered a scalar reference
(read access). And server-side Perl can generate client-side
ECMAScript-conforming code. Now imagine what it would mean to escape each
and every `$' in that generated code in order to prevent it from being
understood by perl as a reference to a Perl scalar.
About "an initial character" - in some BASIC dialects (including the
British made Sinclair BASIC btw) $ denotes string value as opposed to
numeric value and placed as the end of identifier:
let a = 1;
let a$ = "foobar";
^
What part of "initial" is still unclear? And what meaning would have
BASIC (dialects; that introduced/endorsed the worst of all control
statements: GOTO) to contemporary programming?


PointedEars
 
B

Bart Van der Donck

Thomas 'PointedEars' Lahn asbergered:
That is exactly the point. We are not talking about identifiers in Perl,
but about identifiers in ECMAScript implementations. Yet in Perl (and
other languages used server-side), `$' is a mandatory prefix of identifiers
for scalars, and every standalone $foo is considered a scalar reference
(read access).

That is the general rule, yes. But one can easily use a pragma to
influence such things:
http://search.cpan.org/~abigail/variable-1.1/variable.pm
And server-side Perl can generate client-side
ECMAScript-conforming code.

Sure, as it can generate a T-shirt in a clothes factory or instruct a
plane how to fly.
Now imagine what it would mean to escape each
and every `$' in that generated code in order to prevent it from being
understood by perl as a reference to a Perl scalar.

If you're not familiar with Perl, this is a good remark indeed. It's a
simple mechanism though, called interpolation.

my $javascript = "alert('something')";

print qq{<html>
<body>
<script type="text/javascript">
$javascript
document.write('this is a \$-sign')
</script>
</body>
</html>
};

versus

print q{<html>
<body>
<script type="text/javascript">
document.write('this is a $-sign')
</script>
</body>
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Wed, 31 May 2006 15:15:06 remote, seen in
Randy Webb said:
Dr John Stockton said the following on 5/31/2006 12:48 PM:

Be pedantic if you must.


Let me re-phrase it in a way that you won't be pedantic about it:

JRS is fond of using 1 and 2 character function names and defending that
practice by saying that it is less error prone to typos.

That's quite different; after you learn to read English, it will be time
to learn to write it - concisely and unambiguously, if you don't reject
that as unpatriotic.

I use single character function names in demonstration code, and maybe
for local functions; but I doubt whether you can find examples where I
have suggested that for wider use. But yes, two characters can be
sufficiently mnemonic for a common function ID.
 
R

Randy Webb

Dr John Stockton said the following on 6/1/2006 7:14 AM:
JRS: In article <[email protected]>, dated
Wed, 31 May 2006 15:15:06 remote, seen in

That's quite different; after you learn to read English, it will be time
to learn to write it - concisely and unambiguously, if you don't reject
that as unpatriotic.

After you learn to read and understand what is written, maybe you can
attempt to preach to me about English. And while you are at it, you
might want to learn a little bit about the different dialects in use
around the World. I know, it is a stretch for you to even remotely
comprehend the implications of different dialects but I am sure you can
handle it.

While you are attempting to learn, you may want to learn the meaning of
a demonstrative example and try to understand the meaning of what people
say/write rather than continue with your pedantic behavior.
 
J

John G Harris

<OT>
"$ only for autogenerated code":- plain junk.
<snip>

How do you feel about the opposite case where ECMA 262 allows something
but someone has grabbed it for their own use. Specifically, you're not
allowed to start a comment with
/**
nor with
//letter (i.e. no space after the //).

John
 
R

Randy Webb

John G Harris said the following on 6/1/2006 3:28 PM:
<snip>

How do you feel about the opposite case where ECMA 262 allows something
but someone has grabbed it for their own use.

Then nobody conforms to ECMA 262 and that means no browser/UA on the
planet is compliant. It just goes back to me saying that ECMA262 is a
good theory.....

But then it gets defended by saying that "The specs allow you to extend
this specification"
 
V

VK

John said:
How do you feel about the opposite case where ECMA 262 allows something
but someone has grabbed it for their own use. Specifically, you're not
allowed to start a comment with
/**
nor with
//letter (i.e. no space after the //).

Depends on who and why did grab it and how widely is it used.

Java-style comments for POD (your first example) is something to
respect as this notation is in use and there are programs for POD
parsing. "something to respect" means /should/ be respected, not /must/
be.

The second case is not known to me so I personally would disregard it -
unless instructed otherwise for a particular project.

As it was pointed numerous times by some people, c.l.j. cabbal could
write their own perfectly correct library and use instead of $ anything
else from underscore to \u-escaped Chinese hieroglyph. With good docs
and support it would be possibly much more popular than prototype.js
Instead they opted for explaining why libraries of any kind are bad as
such so they let other people to fulfill the demand. There are actions
and the consequences of these actions, so now they may end up by adding
extra check for (typeof $ == 'function') to make their code functional
anywhere outside of c.l.j. (if the things keep going in the same
direction with the same speed).
 
R

Randy Webb

VK said the following on 6/2/2006 3:36 AM:
Depends on who and why did grab it and how widely is it used.

The first is the opening of a multi-line comment and the second is the
opening of a single line comment in JS.
Java-style comments for POD (your first example) is something to
respect as this notation is in use and there are programs for POD
parsing. "something to respect" means /should/ be respected, not /must/
be.

Whether it is Java-style, C++ style, or moon walking style is
irrelevant. It is a very established convention in Javascript.
The second case is not known to me so I personally would disregard it -
unless instructed otherwise for a particular project.

// single line comment.
// This construct is not known to you?
As it was pointed numerous times by some people, c.l.j. cabbal could
write their own perfectly correct library and use instead of $ anything
else from underscore to \u-escaped Chinese hieroglyph. With good docs
and support it would be possibly much more popular than prototype.js
Instead they opted for explaining why libraries of any kind are bad as
such so they let other people to fulfill the demand. There are actions
and the consequences of these actions, so now they may end up by adding
extra check for (typeof $ == 'function') to make their code functional
anywhere outside of c.l.j. (if the things keep going in the same
direction with the same speed).

What does anything in that paragraph have to do with anything about
single and multiple line comments that was asked about?
 
V

VK

Randy said:
VK said the following on 6/2/2006 3:36 AM:

The first is the opening of a multi-line comment and the second is the
opening of a single line comment in JS.

Thanks for the enlightment :), but you did not get the point: it was
asked about
/** (opening of a multi-line comment followed by asterix)
wich if used in Java-like POD generators to signal the parser that this
comment is to be parsed into POD segment (a piece of documentation).

As I said I did not know what does
//char (single line comment followed by a char w/o space)
mean but I presume some another convention for some other
parser/interpreter.

This is why relevant to the "$ sign identifier" discussion: the poster
asked my if I like if some construct/identifier/pretty-print, perfectly
legal for the given language, is taken/reserved by some 3rd party for
some specific use.
 
P

pochartrand

How do you guys feel about wasting your time on arguing wether or not
'$' should be used as a function name... or worse, how to start
comments...
 
J

John G Harris

How do you guys feel about wasting your time on arguing wether or not
'$' should be used as a function name... or worse, how to start
comments...

It's great!

It makes a change from job adverts.

It makes a change from troubles using prototype.js.

It makes a change from Date problems.


Does anyone know if Outlook Express still turns
//A
into
file://A
or has Microsoft stopped doing that?

John
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top