On 7/10/07, skaller <[EMAIL PROTECTED]> wrote: > So actually we have not got this right yet. > > The last version of Felix added typeclasses, and it > changed the whole way we approached making libraries: > we start to use typeclasses instead of open overloading, > but typeclasses make you think much harder about your > abstractions, which is good. But the conversion isn't > finished because we're still confused.. this isn't > a Felix language issue but a library issue. > > It needs to be driven by what users expect tempered > with a nice theoretical model .. so .. > > What do you want?
Consider an I/O model based on promises/futures with continuations. By this, I mean that all I/O calls return a promise. When the code needs the results of the I/O to complete, it invokes a "when(promise) { ... }" which waits until the promise/future has settled to a value, ie. the I/O has completed, then continues the computation with that value. In essence, "when" just takes a continuation for the rest of the computation, and queues it on the promise. So, in pseudo OCaml: let processFile fd = let bytes = (read fd 1024) in (* read() returns a promise for a string *) let otherstuff = (* do some other processing which does not depend on bytes *) in when bytes do print bytes; (* do something else with bytes *) ;; is auto-transformed into: let processFile fd = let bytes = (read fd 1024) in let otherstuff = (* do some other processing which does not depend on bytes *) in when bytes (fun bytes:string -> print bytes; (* do something with bytes *)) ;; When 'bytes' settles to a value, the anonymous function is invoked, but the pre-transformation code still looks sequential and quite straightforward. I believe this achieves optimal asynchrony with very little mental overhead. It's the approach I plan to use in my VM. You can take this even further and make all computation via such calls, and concurrency reduces to safe event-loops. See "Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control" [1]. Sandro [1] http://www.erights.org/talks/thesis/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language