Thanks for your response Joel On 3 Aug 2009, at 20:01, Joel Webber wrote:
> What you're describing is formal support for continuations in the > compiler. While I'm sure this is theoretically tractable, there are > several practical issues that are likely to be problematic. Well yes I guess I am! > Imagine the following case: > > Data data = service.getSomeData(); > // code really returns here, and perhaps in several hundred ms calls > the following: > showDataInUi(data); > > There's nothing obvious to indicate to the developer that it is > necessary to deal with the intermediate UI state -- data has been > requested, and will be shoved into the UI in "a while". What should > I do to the UI to indicate this state? Should I display a > "loading..." box somewhere? Should I disable UI elements that might > allow the user to navigate away from the part of the UI that will be > used to display the results? What happens if showDataInUi() is > called, but the UI's no longer there? These are all important > questions to think of, and obscuring the async nature of the call > makes it all the more likely that developers will ignore them. This seems no different from the issues faced in any real multi threaded UI environment. > The second problem is that it makes the potential error states even > less obvious. I suspect an onFailure() could be transformed into a > normal exception, but it would be even less obvious to the developer > than it currently is that it's likely to happen. Checked exceptions could be used here. But again, if unchecked were kept the dangers are not unusual. Every developer is accustomed to catching RuntimeExceptions at a higher level and dealing with them. In fact it gives more flexibility to handle exceptions once at a higher level rather than at every possible source. > Finally, there's the implementation issue, that a stack frame cannot > be "resumed" in Javascript as it can in other languages/VMs with > formal continuation support (c.f. > http://en.wikipedia.org/wiki/Call-with-current-continuation) > . From a brief googling I can see that some people have made continuation style javascript libraries which makes me think that it might be possible. I am sure there are a lot of complications - but if it makes the thousands of GWT users code more simple and is hidden by the compiler... it would be a much nicer programming model I can see that my last example would not carry the frame context into the "continuation". But something like this would (no?): function firstBit() { function secondBit(var prices) { alert("first bit done"); function thirdBit(var result) { alert("all done" + result); } callAsync("stockPrice", thirdBit); } callAsync("stockPrice", secondBit); } > I believe this will lead to subtle changes in behavior that will be > very surprising in practice. That is something that I cannot comment on. If you scripting geniuses say it can't work then I accept that. But if it could then it would take a small bit of complication out of a lot of developers jobs. Thanks, John --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
