From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7693DBDFB for ; Thu, 1 Sep 2005 15:51:20 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j81DpJVZ032237 for ; Thu, 1 Sep 2005 15:51:19 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA23119 for ; Thu, 1 Sep 2005 15:51:19 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j81DpHMA032232 for ; Thu, 1 Sep 2005 15:51:18 +0200 Received: from rosella (ppp32-47.lns1.syd6.internode.on.net [59.167.32.47]) by smtp1.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id j81DoqoH091650; Thu, 1 Sep 2005 23:20:53 +0930 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Re: Feeding the OCaml GUI troll From: skaller To: David MENTRE Cc: Matt Gushee , caml-list@inria.fr, ocaml-gui@googlegroups.com In-Reply-To: <3d13dcfc0509010628155a4d6e@mail.gmail.com> References: <20050830174757.99765.qmail@web30510.mail.mud.yahoo.com> <200508302001.58080.jon@ffconsultancy.com> <3d13dcfc05083101487092acd5@mail.gmail.com> <43168841.9000302@havenrock.com> <1125580528.7192.23.camel@localhost.localdomain> <3d13dcfc0509010628155a4d6e@mail.gmail.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Kcgl3YBrIh5LdjJqCnhE" Date: Thu, 01 Sep 2005 23:50:52 +1000 Message-Id: <1125582652.7192.52.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 X-Miltered: at concorde with ID 43170757.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43170755.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 callbacks:01 threads:01 threads:01 ocaml:01 handler:01 stack:01 mlton:01 mlton:01 stack:01 compactor:01 ...:98 ...:98 wrote:01 X-Attachments: type="application/pgp-signature" name="signature.asc" X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 --=-Kcgl3YBrIh5LdjJqCnhE Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2005-09-01 at 15:28 +0200, David MENTRE wrote: > Hello, >=20 > 2005/9/1, skaller : > > I am. My idea is this: GET RID OF CALLBACKS. > > The idea is to use (user space) threads instead. >=20 > The main issue with threads is that as soon as you want to share > state/data between threads, it becomes a mess.=20 Ah .. but read again: *user space* threads. Such as those generated by Felix. They're C++, but a control inverter for Ocaml shouldn't be too hard. > The callback and main event handler scheme as the advantage of > simplicity: your program does only one thing at a time. Same as user space threads. In Felix, something like this happens: class f: public continuation { f(caller, args) {=20 _caller =3D caller;=20 arg =3D args; } continuation *resume() { //read event switch (pc) {=20 ... read_flag =3D true;=20 pe =3D &event; // where to put the event pc =3D 99; return this; case 99: =09 // call subroutine(x) pc =3D 100; return new subroutine(this,x); case 100: ... // return return _caller; } }; The driver loop is (crudely): while(p){ p=3Dp->resume(); if(p->read_flag =3D=3D true){ p->pe =3D next_event(); p->read_flag =3D false; } } for a single thread. There's nothing here that can't be done with an Ocaml class instead of a C++ one. Probably, even with camlp4. The main problem is that you can only yield when the machine stack is empty, which means you HAVE to use continuations everywhere you might want to read an event/yield. MLton threads do this much better than Felix: they use an MLton stack, not the machine stack, and the MLton stack is kept linear using the GC's compactor so it grows and shrinks *without* losing linearity .. I wish I could do that in Felix. --=20 John Skaller --=-Kcgl3YBrIh5LdjJqCnhE Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBDFwc8sRp8/9aGVGsRAto8AJwKTdY11Y3/K7dO5CD7ViOEXYC+bwCeNBbt GCkaaXYIkmo5ZjCwYsLgrOI= =+dzU -----END PGP SIGNATURE----- --=-Kcgl3YBrIh5LdjJqCnhE--