|
From: Donal K. F. <don...@ma...> - 2008-08-29 13:04:30
|
Lars Hellström wrote: > Not sure how efficiency would fit into any of this It doesn't appear to do so at all with what you've proposed. ;-) > I'm not considering coroutines in general, I'm just comparing > [suspend]/[resume] with the existing [tcl::unsupported::coroutine]. In > this comparison: > > 1. [suspend]/[resume] gets some additional power from having its > continuation under a Tcl_Obj wrapper. Example of applications: > * Transport across thread boundaries. You can't do that unless you have the state be entirely explicit. If you are relying on some critical piece of state that can only exist in the non-string representation, you can't go to another thread because inter-thread messaging (other than via the shared variable primitives of the Thread extension) is strictly string-based. Either you'll need to do much more magic (and locks and ...) or you'll not have suspend/resume that work in the way we currently understand them to. > 2. [suspend]/[resume] gets further additional power from the > exposure the implementation details, since this means they > can fiddle around with the state at that level. > Example of application: > * Undoing [upvar]s: [suspend], have the TCL_SUSPEND handler > remove the part of the continuation that encodes this [upvar]ing, > [resume] the modified continuation. In that case you are using a non-Tcl state/value model. The Tcl value model is that of immutable transparent strings; you've got what you've got (it doesn't change under your feet), you can see what you've got (you can look inside), and do anything you like with it (e.g. you can stuff it over a channel trivially). Things that cannot meet that model are not Tcl values, and must be dealt with through named handles. > Whether it is a good idea to exercise the second category of powers is > debatable (it's a bit like POKE in the old BASIC era), but the power is > a consequence of the model. Those powers seem (without studying anything very hard) to violate the Tcl value model, so "good idea" is an enormously long way from my view on the matter. ;-) Donal. |