Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: David MENTRE <david.mentre@gmail.com>
Cc: Matt Gushee <mgushee@havenrock.com>,
	caml-list@inria.fr, ocaml-gui@googlegroups.com
Subject: Re: [Caml-list] Re: Feeding the OCaml GUI troll
Date: Thu, 01 Sep 2005 23:50:52 +1000	[thread overview]
Message-ID: <1125582652.7192.52.camel@localhost.localdomain> (raw)
In-Reply-To: <3d13dcfc0509010628155a4d6e@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]

On Thu, 2005-09-01 at 15:28 +0200, David MENTRE wrote:
> Hello,
> 
> 2005/9/1, skaller <skaller@users.sourceforge.net>:
> > I am. My idea is this: GET RID OF CALLBACKS.
> > The idea is to use (user space) threads instead.
> 
> The main issue with threads is that as soon as you want to share
> state/data between threads, it becomes a mess. 

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) { 
	_caller = caller; 
	arg = args;
}

continuation *resume() {

	//read event
	switch (pc) { 
	...
		read_flag = true; 
		pe = &event; // where to put the event
		pc = 99;
		return this;
	case 99:
		
	// call subroutine(x)
		pc = 100;
		return new subroutine(this,x);
	case 100:
	...

	// return
		return _caller;

}
};


The driver loop is (crudely):

	while(p){
		p=p->resume();
		if(p->read_flag == true){
			p->pe = next_event();
			p->read_flag = 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.


-- 
John Skaller <skaller at users dot sourceforge dot net>


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-09-01 13:51 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-28 15:38 Does LablTk have a future? Matt Gushee
     [not found] ` <aefe758210f7fa0b9846b0ea4278cf3a@rouaix.org>
2005-08-28 23:21   ` [Caml-list] " Matt Gushee
2005-08-29 22:33 ` Jon Harrop
2005-08-30  4:39   ` Matt Gushee
2005-08-30 11:39     ` Yaron Minsky
2005-08-30 11:48     ` Jon Harrop
2005-08-30 12:22       ` David MENTRE
2005-08-30 13:45         ` Jon Harrop
2005-08-30 15:47           ` David MENTRE
2005-08-30 16:08             ` Jon Harrop
2005-09-01  4:25               ` Matt Gushee
2005-09-01 11:20                 ` Matt Gushee
2005-09-01 11:26                   ` Matt Gushee
2005-09-01 14:09                 ` Chris Campbell
2005-08-30 16:21           ` Bardur Arantsson
2005-08-30 17:47           ` [Caml-list] " David Thomas
2005-08-30 18:06             ` Tyler Eaves
2005-08-30 19:01             ` Jon Harrop
2005-08-30 22:55               ` Chris Campbell
     [not found]               ` <c22844d10508301553b54841b@mail.gmail.com>
2005-08-30 22:56                 ` Fwd: " Chris Campbell
2005-08-30 23:04                   ` Doug Kirk
2005-08-31  0:08                   ` Fwd: " Jon Harrop
2005-08-31  0:31                     ` Olivier Andrieu
2005-08-31  8:48               ` Feeding the OCaml GUI troll (was: Re: [Caml-list] Does LablTk have a future?) David MENTRE
2005-08-31  9:06                 ` Proposal a GUI from Ocamlsdl Christophe Raffalli
2005-08-31 14:39                   ` [Caml-list] " Jon Harrop
2005-09-01 19:27                     ` Nathaniel Gray
2005-08-31 14:27                 ` Feeding the OCaml GUI troll (was: Re: [Caml-list] Does LablTk have a future?) Jon Harrop
2005-09-01  4:49                 ` Feeding the OCaml GUI troll Matt Gushee
2005-09-01 13:15                   ` [Caml-list] " skaller
2005-09-01 13:28                     ` David MENTRE
2005-09-01 13:50                       ` skaller [this message]
2005-09-01 14:43                     ` Chris Campbell
2005-09-02  7:40                     ` Ville-Pertti Keinonen
2005-09-02 12:39                       ` skaller
2005-09-03 10:34                         ` Damien Bobillot
2005-09-03 12:30                           ` skaller
2005-09-04 14:08                           ` Richard Jones
2005-09-03 11:10                         ` yoann padioleau
2005-09-03 11:30                           ` Jonathan Roewen
2005-09-03 17:23                           ` Doug Kirk
2005-09-04 14:01                         ` Richard Jones
2005-09-01 19:23                 ` Feeding the OCaml GUI troll (was: Re: [Caml-list] Does LablTk have a future?) Nathaniel Gray
2005-09-01  4:31             ` [Caml-list] Does LablTk have a future? Matt Gushee
2005-09-01  4:17       ` Matt Gushee
2005-09-01 13:25         ` Jon Harrop
2005-08-30  7:16   ` GUI for OCaml (was: Re: [Caml-list] Does LablTk have a future?) David MENTRE
2005-08-30  9:53     ` GUI for OCaml Christophe Raffalli
2005-08-30 10:28       ` [Caml-list] " David MENTRE
2005-08-30 13:04         ` Bünzli Daniel
2005-08-30 17:13         ` David Thomas
2005-08-30 11:18       ` Mark Shinwell
2005-08-30 14:22       ` Jacques Carette
2005-08-30 23:12         ` Pietro Abate
2005-08-30 14:14     ` GUI for OCaml (was: Re: [Caml-list] Does LablTk have a future?) Richard Jones
2005-08-30 15:33       ` mmzeeman
2005-08-30 15:44         ` Jon Harrop
2005-08-30 22:34         ` yoann padioleau
2005-09-01  4:58           ` Matt Gushee
2005-08-30 16:01       ` Jon Harrop
2005-08-30 16:25         ` Chris Campbell
2005-08-30 22:49           ` yoann padioleau
2005-08-30 16:03       ` Chris Campbell
2005-08-30 22:31     ` yoann padioleau
2005-08-31  8:19       ` About Lablgtk2 (was: e: GUI for OCaml) David MENTRE
2005-09-03 11:41         ` yoann padioleau
2005-08-30 17:35   ` [Caml-list] Does LablTk have a future? Olivier Andrieu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1125582652.7192.52.camel@localhost.localdomain \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=david.mentre@gmail.com \
    --cc=mgushee@havenrock.com \
    --cc=ocaml-gui@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox