VK wrote:
> RobG wrote:
>
>>If you are discussing your stubbornness, then yes, it is demonstrated.
>
>
> Oh yeh! But not from my part. This why I called it once "a discussion
> about who's God is better". 
>
> You may read an interesting discussion with Mr. Nielsen about the
> previous variant of the article:
> <http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/c12423afa53a28f8/bcf7ad952e27c998#bcf7ad952e27c998>
>
>>Subsequent readings have not changed the text or my understanding of it.
>
>
> I see... So I guess you went through the example with the slice()
> method and it did not change your clear understanding that this method
> (as nearly all others) is simply broken...
Yes I did - I clearly understand what it does.
I can accept you expressing your opinion within this forum, but if you
are going to try to teach people about JavaScript arrays you need to
clearly separate fact from opinion.
Using your example and with a copy of the ECMAScript Language
Specification 3rd Edition December 1999 handy:
Quote:
var arrayOne = new Array();
arrayOne[0] = "foo"
arrayOne[100] = "bar"
var arrayTwo = arrayOne.slice(0,50);
// arrayTwo.length == 50
|
arrayTwo will consist of the elements 0 up to but not including 50 of
arrayOne and therefore have a length of 50 (as per section 15.4.4.10).
arrayTwo[0] will be "foo"; all the other elements are undefined.
arrayTwo may actually have one defined element and 49 undefined ones,
or just one defined element and a length of 50 - however it is
actually implemented is irrelevant 99.99% of the time.
Quote:
// But:
var arrayTwo = arrayOne.slice(99,200);
// arrayTwo.length == 2
// Only "in-within array" elements are counted
|
Which is exactly as per the specification - if the 'end' (in this case
200) is beyond arrayOne's length, then only the elements up to the end
of arrayOne are included. The second slice operation is the same as:
arrayTwo = arrayOne.slice( 99, arrayOne.length );
or
arrayTwo = [ arrayOne[99], arrayOne[100] ];
or
arrayTwo[1] = arrayOne[100];
in all cases, arrayTwo[0] will be undefined and arrayTwo.length = 2.
You then go on to assert:
Quote:
As you can see, despite that mechanically (on the memory level) we
have only two elements in the entire arrayOne (arrayOne[0] and
arrayOne[100]), programmatically we have one continuos array of 101
element in total:
"foo", undefined, undefined, ... , undefined, "bar"
|
Which is your interpretation of things. Rather than use the
specification to state exactly what has occurred, you have chosen to
introduce your own jargon and leave readers confused.
You need to decide if you are teaching ECMAScript Language or VK's
opinion on life, the universe and everything.
> It gives a good credit to your believe. My good luck to you to use
> arrays in the matrix analysis. It's going to be as difficult as
> navigate across the globe while thinking that the Earth is flat and
> stays on three elephants.
Is it reasonable to make inferences about my system of beliefs based
on usage of a particular programming language? ;-p
And if my success so far is any measure, I'd have found your challenge
a doddle - pity the darn thing is an ovate spheroid (or so some believe).
>
>>The ECMA specification does not say...
>
>
> ECMA doesn't need to say anything particular about array, as well as
> define what "object", "algorithm", "program" and so is. These entities
> appeared long before ECMA. So if you need to know what array is, ECMA
> is not an authority of any kind. Their humble task was just include
> properly and in proper relations with other sections, something that
> was invented and described long before anyone of them got her/his first
> payroll check. In this concern IBM repository is much more reliable
> source of information:
> <http://publib.boulder.ibm.com>
And that's the central issue - clearly pointing out on the one hand
what the spec says and on the other how arrays or other objects are
used in general in other contexts.
The ECMAScript Language specification is not an authority on arrays in
general, but it does prescribe the basic properties of JavaScript
arrays and therefore must be used as the primary reference when
describing their properties or behaviour.
[...]
--
Rob