Re: undefined vs. undefined (was: new Array() vs [])
- From: "Richard Cornford" <Richard@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 10 Sep 2006 14:47:04 +0100
VK wrote:
VK wrote:
So indeed it is confirmed to be
a Gecko JavaScript engine bug: see
<https://bugzilla.mozilla.org/show_bug.cgi?id=260106>
So I was wrong and Microsoft was right in this case.
*IMHO*
Your opinions are worthless, for reasons that will once again become
clear.
After thinking it over again tonight,
Don't confuse your mental processes with thinking (at least in the sense
that everyone else uses the term).
I see no bug in Mozilla.
So where everyone else sees a bug, including the people who wrote the
script engine for Mozilla, you don't see one.
But I see a specification bug in the referenced
ECMAScript section 11.1.4 which is in turn a
reflection of erroneus decision once made to allow
undefined value to be *assigned*.
Quote 1
4.3.9 Undefined Value
The undefined value is a primitive value used
when a variable has not been assigned a value.
The mechanism for which ("used when a variable has not been assigned a
value") is laied out in section 10.1.3 under "Variable Instantiation".
Quote 2
8.1 The Undefined Type
The Undefined type has exactly one value, called undefined.
Any variable that has not been assigned a value has
the value undefined.
Quote 3
11.1.4 Array Initialiser, preface
... Elided array elements are not defined.
The distinction between a 'variable', as referred to in section 4.3.9,
and an array element being significant.
Quote 4
11.1.4 Array Initialiser, production
(VK: for say [,1,2] array initializer)
So the applicable productions would be the production:
ArrayLiteral : [ ElementList , Elison<opt> ]
- including the production:
ElementList: Elision<opt> AssignmentExpression.
...
1. Create a new array as if by the expression new Array().
2. Evaluate Elision; if not present, use the numeric value zero.
This is not the algorithm for - [,1,2] -, it is the algorithm for -
[,,] - and the like. The production:
ArrayLiteral: [ Elision<opt> ]
If you are going to make statements about the interpretation of ECMA 262
you should at lest refer to the relevant sections.
3. Call the [[Put]] method of Result(1) with arguments
"length" and Result(2).
Note that the property name being assigned to here is "lenght".
4. Return Result(1).<snip>
...
Quote 5
8.6.2.2 [[Put]] (P, V)
The special [[Put]] method of Arrays is defined in section 15.4.5.1 and
differs from the standard object [[Put]] method quoted here.
This way I see a specification bug in 11.1.4
You read the wrong ArrayLiteral algorithm(s) and use the wrong [[Put]]
method and you see a "specification bug"?
where the preface is in
contradiction with the production.
Is that the production you referred to or the applicable productions?
By going by the production, it is not possible to have
"not defined" members in place of elision.
You omitted to cover the productions for Elision:-
The production Elision :, is evaluated as follows:
1. Return the numeric value 1.
The production Elision : Elision, is evaluated as follows:
1. Evaluate Elision.
2. Return (Result(1)+1).
So in your cited algorithm, applied to [,,]:-
| 2. Evaluate Elision; if not present, use the numeric value zero.
- the numeric value is going to be two. And then:-
| 3. Call the [[Put]] method of Result(1) with arguments
| "length" and Result(2).
- writes the value 2 to the length property of the array, without
defining, or assigning to, any actual array elements.
So in what sense if it "not possible to have "not defined" members in
place of elision"? Here the length is 2 and the array has no other
defined properties, as a result of two Elisions in the Array literal.
There is an explicit assignment (set) operation involved,
To the 'length' property.
therefore we only can have *members explicetly
initialized with undefined value*.
You have not shown any.
In this respect if we want
arr = [,1,2];
to produce an array that can be treated it as an object
with two properties ("1" and "2", but not "0"): then
we also have to request
that
obj = {};
obj.foo = undefined;
would result in an object with no enumerable properties
(no <foo> property).
Such has not been demonstrated here. In the case of the array no
explicit assignment is made to a property with the name '0', while in
the case of the object a property named 'foo' has been explicitly
assigned a value.
Technically by the production schema these are totally
the same,
Even if they were, and they are not, how would you know? What you
understand of what you read differs significantly from the meaning of
what you read.
but no one seems filing a bug for the later.
OK. There is a mental processing bug in VK's mind that leaves him
incapable of perceiving reality. You may consider the bug reoprted to
the responsible party.
<snip>
Section 11.1.4 requires two opposite things in preface
section and in production section, so it's the
programmer's choice what to follow.
No contradiction exists. Elision evaluation either only changes the -
length - property of an array or it only offsets the index where the
results of AssignmentExpressions are stored (with consequential effects
on the - length -).
Here some code I've made while making my mind<snip>
together :-) :
LOL
Richard.
.
- References:
- undefined vs. undefined (was: new Array() vs [])
- From: VK
- Re: undefined vs. undefined (was: new Array() vs [])
- From: Richard Cornford
- Re: undefined vs. undefined (was: new Array() vs [])
- From: VK
- Re: undefined vs. undefined (was: new Array() vs [])
- From: Richard Cornford
- Re: undefined vs. undefined (was: new Array() vs [])
- From: VK
- Re: undefined vs. undefined (was: new Array() vs [])
- From: VK
- undefined vs. undefined (was: new Array() vs [])
- Prev by Date: Re: Color computation
- Next by Date: Re: FAQ Topic - How do I detect Opera/Netscape/IE?
- Previous by thread: Re: undefined vs. undefined (was: new Array() vs [])
- Next by thread: Re: undefined vs. undefined (was: new Array() vs [])
- Index(es):
Relevant Pages
|