Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #11168

Re: Comparing arraies

Message-ID <44279053.ug29IgtNvP@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-02-02 23:09 +0100
Subject Re: Comparing arraies
Newsgroups comp.lang.javascript
References (11 earlier) <dcc3712e-f1d1-41d6-80c1-8821b314034f@s7g2000vby.googlegroups.com> <3325601.CWPS83hRNz@PointedEars.de> <336bb7d2-5ab8-46ea-88a3-2e5e47cb9663@o20g2000yqh.googlegroups.com> <1949843.mKqTvaHIzj@PointedEars.de> <6fbfd423-02ec-49a8-a3a2-345e9271e74c@k28g2000yqn.googlegroups.com>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Michael Haufe (TNO) wrote:

> Thomas 'PointedEars' Lahn wrote:
>> I am disagreeing with you when you say that (all) operators in a
>> programming language ("programmatic operator(s)") are not true functions
>> in the mathematical sense (are not "mathematical function(s)").  I think
>> they are, because of the reasons I named above.
> 
> Ah, I see. I am specifically referring to JavaScript though and this
> is what I am trying to say with that sentence:
> 
> let "x" represent a particular operator
> 
> let P(x) represent the claim "x is a function"
> 
> ¬(∀x P(x))
> 
> which is equivalent to:
> 
> ∃x ¬P(x)
> 
> I am not trying to say:
> 
> (∀x ¬P(x))
> 
> I hope that is clearer (and of course I hope Google Groups doesn't
> mangle the quantifiers when I hit submit...).

Your statement is clear now, as Google Groups positive-surprisingly kept the 
Unicode characters intact.
 
> But now the burden of proof is on me to prove that there exists an
> operator which is not a function. Luckily for me and my laziness, this
> work has already been done:
> 
> <https://drj11.wordpress.com/2008/07/11/javascript-using-numbers-as-
> table-keys-considered-harmful/>
> 
> So I think   x + ""  would qualify if x is one of the values mentioned
> in the link.
> 
> (I took a glance at the 5.1 spec and that note is still there.)

While the argument on number representation in the referred article might be 
solid, a disturbing (but unfortunately common) amount of inaccuracies, 
misnomers and misconceptions with regard to its environment can be found 
there.  This includes, but might not be limited to:

| […] in JavaScript all tables (associative arrays) are indexed by strings,
| and nothing else."

There are _no_ (built-in) "associative arrays" or "tables" in JavaScript 
(the programming language).  There are *objects* (as required by ES 5.1, 
section 8.6, and corresponding sections of earlier Editions, of which 
JavaScript is stated by the respective vendor [see below] to be an 
implementation of).  [How ECMAScript objects are to be implemented in a 
programming language is _not_ specified.]

Objects are _not_ "indexed by string".  Objects *have properties* with 
String-type names, where with Array instances some property names with 
numeric representation are special (ES 5.1, 15.4).  [That particular 
misconception might be a direct result of David Flanagan's listing `['…`]' 
as "Array/index operator" in his "JavaScript: The Definitive Reference" 
(IIRC).]

| […] when you go a[0] = thing, isn’t that indexing the table `a' with the
| number 0? Well, yes and no.

| So with (small) integer keys there are few possible problems.

`a[0]' is _not_ accessing a "table `a' with the number `0'" or by "integer 
key".  It is accessing a *property* of an *object* by the numeric 
representation of its *property name*.  Likewise, a["0"] is accessing the 
property with the name "0" (for short: "the '0' property") of the object 
*referred to* by the `a' property of the next matching object in the scope 
chain (and potentially by other properties of other objects).

| Given the importance of arrays in JavaScript, […]

| When converting numbers to strings JavaScript requires that the
| parsimonious printing rule is applied.

| In principle a JavaScript implementation could make a different choice
| each time it performed the conversion.

| It would of course be insanity for an implementation to do that, but it’s
| still a loophole in the specification, and it should be closed.

The terms JavaScript and ECMAScript are used interchangeably there.  But 
JavaScript (1.1+) is (merely) *an implementation of* ECMAScript, originally 
by (Brendan Eich of) the Netscape Communications Corporation, and later the 
Mozilla Organization (Mozilla.org).

The article is speaking about "JavaScript implementations".  However, there 
are, in a manner of speaking, AFAIK only two production-quality JavaScript 
implementations: SpiderMonkey (with improvements TraceMonkey and 
JägerMonkey), and Rhino [1, 2].  [There is also a test implementation of 
what was then called "JavaScript 2.0", itself an implementation of 
Netscape's (Waldemar Horwat's) proposal for ECMAScript Edition 4, called 
Epimetheus (as in Greek mythology) [2], see also [3].]

All other implementations that this concerns are *ECMAScript* 
implementations.  This is important because "varying between 
implementations" with regard to the ECMAScript Language Specification means, 
of course, "varying between *ECMAScript* implementations".

I will look into said argument later, but this needed pointing out right 
now.


PointedEars
___________
[1] <https://developer.mozilla.org/en/JavaScript>
[2] <https://developer.mozilla.org/en/JavaScript_Language_Resources>
[3] "Google Tech Talk – Changes to JavaScript, Part 1: EcmaScript 5", with
    Mark Miller, Waldemar Horwat, and Mike Samuel.
    <http://www.youtube.com/watch?v=Kq4FpMe6cRs>
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Comparing arraies Archos <raul.san@sent.com> - 2012-01-26 07:23 -0800
  Re: Comparing arraies Martin Honnen <mahotrash@yahoo.de> - 2012-01-26 18:29 +0100
    Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-26 19:50 +0100
      Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-26 19:54 +0100
        Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-27 16:49 +0000
          Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-27 18:41 +0100
            Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-28 11:28 +0000
              Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-28 21:17 +0100
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-29 14:55 +0000
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-29 17:13 +0100
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-30 15:27 +0000
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-30 19:03 +0100
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-31 15:07 +0000
                Re: Comparing arraies Dr J R Stockton <reply1205@merlyn.demon.co.uk> - 2012-01-31 18:51 +0000
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-30 12:01 -0800
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-31 11:06 +0000
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-31 06:08 -0800
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-31 16:08 +0000
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-31 18:32 -0800
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-01 17:02 +0000
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-01 10:07 -0800
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-02 15:10 +0000
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-02 11:16 -0800
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-07 15:14 +0000
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-01 21:45 +0100
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-01 13:07 -0800
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-01 23:44 +0100
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-01 18:22 -0800
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-02 23:09 +0100
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-03 01:47 +0100
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-04 10:34 +0000
                Re: Comparing arraies Dr J R Stockton <reply1205@merlyn.demon.co.uk> - 2012-02-05 16:47 +0000
                Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-06 15:21 +0000
                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-04 23:37 -0800
    Re: Comparing arraies Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-26 23:08 +0000
      Re: Comparing arraies Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-27 01:42 +0000
        Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-27 11:41 +0100
      Re: Comparing arraies Gene Wirchenko <genew@ocis.net> - 2012-01-26 16:24 -0800
        Re: Comparing arraies "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-27 08:50 +0000
      Re: Comparing arraies Dr J R Stockton <reply1204@merlyn.demon.co.uk> - 2012-01-27 21:07 +0000
        Re: Comparing arraies "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-28 13:45 +0000
  Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-26 16:21 -0800
    Re: Comparing arraies Martin Honnen <mahotrash@yahoo.de> - 2012-01-27 16:00 +0100

csiph-web