On 3/31/07, skaller <[EMAIL PROTECTED]> wrote: > Reactive programming with callbacks is exactly the mess Felix > is designed to eliminate -- Felix threads are event driven, > but you can write modular code using thread style and channels.
There are no callbacks in FRP (at least the style I'm used to)... callbacks are exactly the mess FRP is designed to eliminate :) Though an FRP system could be internally based on callbacks, it could just as easily be based on something like pthreads and look the same to the user. > However making this work with integrated GUI systems like > Gtk isn't so easy because both systems want to run their > own event loops. Although you can create callbacks in Felix, > you don't want to because they can't communicate with channels. > And you don't want functional code for the same reason. > In particular, you can't call the garbage collector unless > the machine stack is empty, because it has no way to trace > the machine stack. The "F" in "FRP" is a little misleading... it's not so much that there's functional programming going on, it's that there's no imperative programming happening since constructs such as callbacks and mutable state are eliminated. But there's not much recursion happening... although one might be tempted to traverse the dependency graph using a DFS, you can do it without any recursion by using a topological sort (this is how PLT Scheme's FrTime works IIRC). Unfortunately this means the stack still isn't empty until the entire graph is traversed (you've still got a while loop and a priority queue) but there's probably a way around this too. > There is a solution: map gtk onto a socket, and use two > pthreads. But there is another solution: use a properly > designed Gui such as X or MS-Windows, not a system > that tries to own the event loop. > > Gtk may provide a way to construct your own event loop, > but I'm not sure. Tcl/TK used to allow even loop merging. > I actually looked in Gtk but I couldn't see one. > If you can figure a way of doing it, let me know! gtk_main_iteration_do() [1] looks promising... it checks if there's any events pending, and if so, dispatches (one of?) them. It comes in blocking and non-blocking varieties. Speaking of X11... have you checked out XCB [2]? It's X.org's replacement for Xlib. One of its features is "latency hiding", which, instead of enforcing the request/response/request/response order of Xlib, allows you to send out multiple requests without blocking and receive their responses in arbitrary order. It seems like a good fit for Felix's pthreads (with each XCB "cookie" corresponding to an ichannel), but the devil may be in the details, I'm not sure. I've played around with it a little in Felix... flxcc did a beautiful job of wrapping the library :) - Chris [1] http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-main-iteration-do [2] http://xcb.freedesktop.org/wiki/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Felix-language mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/felix-language
