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

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?  

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

- Jim  

-----Original Message-----
From: David Junger [mailto:tffy@free.fr] 
Sent: Wednesday, April 03, 2013 1:14 PM
To: VBWG Public (www-voice@w3.org)
Subject: Re: Sharing state with invoked SCXML interpreters [was DOM in _event.data and KVPs]

Le 3 apr 2013 à 16:33, Jim Barnett a écrit :

> That's a good question.  I'm no expert on JavaScript, however if you are using the SCXML Event I/O Processor, you can do whatever you want since its implementation is platform-specific.

Yeah, I can do whatever I want, as long as I don't just pass references, right? ;)

I can't recall if the SCXML draft requires lossless data transmission (either over basichttp or scxml) but it is certainly nice to have that, and if you don't have that, as an author, it's nice to know what you do have. Saying nothing means that reading the SCXML spec won't tell you how to actually use the SCXML event I/O processor with the ECMAScript datamodel.

Well, it's possible to almost fully serialize a JavaScript object (closure variables won't be there) but it's neither standard nor safe.

There is, however, a 'structured clone' algorithm described in the HTML living standard and already implemented in a few browsers, that is more powerful than JSON but quite safe. It's still limited but at least you can have cyclic references, and some useful values like RegExes.
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#structured-clone

It's worth noting that this algorithm is now used for passing DOM event data between Web pages that aren't allowed to share references, and to/from Web Workers (which run in a separate thread and so are unable to share references).
I think if it's good enough for HTML, it should be good enough for us.


> It's worth some thought whether we need to say anything about serialization when using the Basic HTTP Event I/O Processor.  However even if we specified something for it, the spec still wouldn't say anything about how to pass data with the SCXML event i/o processor because you're not expected to interoperate with anyone else's implementation using it.

That's a shame. But since I'm not implementing basichttp, I can let you guys live with that :p

			David

Received on Wednesday, 3 April 2013 17:39:47 UTC