From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B0FF2BBAF for ; Fri, 25 Jul 2008 17:30:00 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjMCAByOiUiVnFmTiGdsb2JhbACSWAEBAQ8gnRY X-IronPort-AV: E=Sophos;i="4.31,253,1215381600"; d="scan'208";a="27674871" Received: from mail.uj.edu.pl ([149.156.89.147]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Jul 2008 17:29:59 +0200 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=ISO-8859-1; format=flowed Received: from [137.73.5.196] by mail.uj.edu.pl (Sun Java(tm) System Messaging Server 6.3-5.02 (built Oct 12 2007; 32bit)) with ESMTPA id <0K4K0070RJ1NA070@mail.uj.edu.pl> for caml-list@yquem.inria.fr; Fri, 25 Jul 2008 17:29:48 +0200 (CEST) Message-id: <4889F16B.3020903@uj.edu.pl> Date: Fri, 25 Jul 2008 16:29:47 +0100 From: Dawid Toton User-Agent: Thunderbird 1.5.0.12 (X11/20080430) To: caml-list@yquem.inria.fr Subject: 'Nondeterministic' evaluation wrt exceptions X-Spam: no; 0.00; ocaml:01 corresponds:01 node:01 calcs:01 ocaml:01 calcs:01 syntax:01 syntax:01 preprocessor:01 exception:01 exception:01 exceptions:01 exceptions:01 data:02 data:02 Let's look at my OCaml program as a poset of function applications. Some its elements throw exceptions. I need to evaluate all applications except of those that 'Follow' exception-throwing ones. This 'Follow' corresponds to the ordering in my poset. Unfortunately standard tools allow only to do this with 'Follow' corresponding to some total order. Could you give me some advice how to evaluate really all applications that precede throwing an exception? ---------- Full story I have many similar programs that do calculations for me. Some steps are very computationally heavy. Every such function do_heavy_thing starts another process (on other computer) and throws an exception that means "the result will be available later". Everything that relies on this result of do_heavy_thing cannot be evaluated. And it won't be because I don't catch the exception. So I run my programs repeatedly. I correct and extend them while heavy_thing is done somewhere else (usually for few days). do_heavy_thing checks for the result. If it's finished at the moment of execution, it downloads the data and returns. Then the data undergoes some cheap transformations and some next do_heavy_thing function can be called. Every time I execute the program I get some more useful output and "Fatal error: exception ..." message. So far this scheme worked very well. This is basically breaking the calculation at some point with respect to a total order (the order of source code). Some calculations should be done in parallel, since there are many of them. I solved this problem with run_many adapter: firstly collect a list of heavy calculations, then execute them as a one node in the total order of evaluation. Currently I hit the following problem: my new programs (call them 'Calcs') are too complex to apply the evasion with run_many. So my latest calculations are done one-by-one. This is so bad, that I can spend several days in order to solve this in a systematical way. These Calcs are managed by other set of OCaml tools. I have complete control over all the code. The tools already do tiny changes to Calcs with simple string operations, not real syntax extension. I hope some witty preprocessor can help. I have no idea what code the syntax extension should produce. My first guess is to wrap everything in type 'a wrapped = Exception | Value 'a and make all aplications evaluated. But this seems to be a big headache. Maybe this is well-known, already solved problem? Any ideas? Dawid