Re: Sharing state with invoked SCXML interpreters [was DOM in _event.data and KVPs]

Le 3 apr 2013 à 19:39, Jim Barnett a écrit :

> Section D.1, item 5 dealing with the SCXML Event I/O Processor says:  
> 
> "The 'data' field of the event raised in the receiving session MUST contain any data specified in the 'namelist' attribute or in <param> or <content> elements in the sending session." 
> 
> That certainly sounds like lossless transmission to me.  Does anyone think it needs to be made more emphatic?  

Well, that's a problem. The "value" of an ECMAScript object is its reference (in fact, that's what its 'valueof' method will return). The string conversion is, in most cases, pretty useless. A clone != the original (using ECMAScript semantics for != ).
So if I take that text litterally, passing objects by reference is the only correct thing to do.


> On the other hand, I probably should add a clause about passing by value, rather than reference. 

As I said, "passing by value" doesn't mean much to objects. Scalar values (strings, booleans, numbers) are always passed by value in ECMAScript unless you explicitly wrap them in their object counterpart.

If you want to say that objects should be cloned, then say that objects should be cloned, but then it's best to say how far the cloning should go.

Another option, also used along with structured clones in HTML, is object "transfer". You pass the object by reference to the target, but you remove all references to it from the source.

			David

Received on Wednesday, 3 April 2013 18:25:33 UTC