Arrays with non-integer properties

Serge LE HUITOUZE slehuitouze at
Mon Oct 15 04:36:09 PDT 2007

Hello there,

I have a question that I tried to solve on a more applicative mailing-list, but which
seem not to interest anybody there ;-)

That's why I'll give it a try on this forum.

Sorry if it's not exactly the right forum, I'm not familiar with EcmaScript and its
various brands, not to mention associated discussion forums/lists.
I'm confident, however, that I will find knowledgeable advice here (or, at least,
redirection to appropriate discussion).

My questions arise from the last version of the W3C SISR standard
( It is used to normalize how one
writes (ECMA-327) code to build semantic information from a voice grammar.

More precisely, my question is about serialization.
A chapter of the afore-mentionned standard is devoted to serializing an ECMA
object in an XML form (a.k.a." EMMA form" in SISR wording). Along this chapter,
interrogations come into play as to how some ECMA objects are serialized in
"ECMA" format: It seems it's such an obvious (sub-)problem in the context of
SISR standard that it is not even mentionned what governs this serialisation.
I make the hypothesis that this format is the same as the way one writes a literal
value in an ECMA program, though I can't get any confirmationon w3.voice forum...

[BTW, I don't know if ECMA's literal syntax is exactly the same as JSON, I'm
interested in any clarification from you on this particular point.]

At some point of SISR chapter 7, more precisely item 5 in section 7.1, I find
the following wording concerning EMMA (i.e. XML) serialization of ECMA arrays:
"Any other properties of an Array object, for instance the keys of an associative
array (e.g. a["prop"]), are subject to the same transformation rules as the
regular properties of an object. In a sparse array, only those elements which
hold defined values will be serialized."

Though this text describes the XML serialization, it clearly has implication on
ECMA serialization as well: Indeed, it asserts as perfectly acceptable that an
array object can have non-integer properties in addition to "regular" index
The question is then: How do you ECMA-serialize an array object having, in addition
to index properties, non-integer properties?

>From what I understand of ECMA-262 (which is little...) the following SISR fragment:
**   v1=new Array; v1.push("A"); v1[3]="B"; $.v1=v1;
should yield the following ECMA serialization: 
**   {v1:["A",,,"B"]}
So would the equivalent ECMA fragment using the literal syntax:
**   v1=["A",,,"B"]; $.v1=v1;

This is (hopefully) straightforward.

But then, what would the following SISR fragment yield?
**   v1=new Array; v1.push("A"); v1[3]="B"; v1["prop"]="C"; $.v1=v1;

>From my (short, but nevertheless painful) search in ECMA reference document,
I was not able to find how you can specify literally an ECMA array with additional
non-integer properties.

The only answer I got on "w3.voice" was one suggesting to use the object notation to
create "something" that mixes integer and non-integer properties. However, this "something"
is nothing more than a regular object (though slightly unusual, since it has integer properites),
not an array object with non-integer properties.
It is thus obviously (at least, that's how I analyse it) not the way one should serialize
such an array.

Comments anyone?

Thanks in advance.

--Serge Le Huitouze

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.14.10/1070 - Release Date: 14/10/2007 09:22

More information about the Es4-discuss mailing list