Re: updated SCXML draft

Le 11 apr 2013 à 16:18, Jim Barnett a écrit :

> For section C.2.8.1 on incoming event data, I think that we could add the following at the start of the paragraph   "In some circumstances, the entity that generated the event may have indicated how the data is to be interpreted. In such cases, the Processor SHOULD try to format the data according to those indications. Otherwise, [existing prose]". 

OK.

Le 11 apr 2013 à 15:55, Jim Barnett a écrit :

>  I'll look at your other comments later, but on C.2.11 I think that you may be looking at an outdated version.  The current prose reads  " The iteration order is the order of the underlying ECMAScript structure, which goes from 0 to length-1 in the case of arrays and strings".  

Oh. Well, that's fine.

> A question related to this:  you say that there are objects for which the iteration order is not defined.  Is it possible to iterate over them?  Is the idea that the platform would determine its own platform-specific order in this case?

1) Yes. Any ECMAScript object can have "enumerable" properties (any author-defined property is enumerable). Iterating over the object with the "for(key in object)" loop will assign, in turn, every enumerable property name in 'object' and its prototype chain to the variable 'key'. However, there is no specified order among the properties of objects. It could be alphabetical, it could be hierarchical then alphabetical, it could be ordered by when the property was created, or it could be ordered in apparent randomness following the underlying hash table, etc. The for…in guarantees that every enumerable property will be visited exactly once, that is all. The order may also change from one iteration to the next, although existing ECMAScript engines don't do that. Arrays and strings get special treatment from for…in, where their enumerable properties are enumerated from zero to length-1 (but it is still necessary to add the ownProperty filter because no courtesy is given to Array's prototype).

2) No. The idea is to have the platform use "for…in" and let its ECMAScript engine do what it does normally.

> If so, should we say "The iteration order is the order of the underlying ECMAScript structure, where this is defined.  In the case of arrays and strings, this goes from 0 to length-1".

It's only defined for arrays and strings, AFAIK, and the definition is what you say. Maybe the new C-like arrays that they added for WebGL also have it. I haven't played with them so far.

Bottom line, the simplest thing to say is: "behave exactly as for(item in object) if(object.hasOwnProperty(item))"

			David

Received on Thursday, 11 April 2013 14:31:12 UTC