From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id E2B2DBBAF for ; Mon, 1 Feb 2010 23:15:39 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.49,385,1262559600"; d="scan'208";a="50712312" Received: from 91-168-178-117.rev.libertysurf.net (HELO [192.168.1.2]) ([91.168.178.117]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Feb 2010 23:15:39 +0100 Message-ID: <4B6751BC.9010402@irisa.fr> Date: Mon, 01 Feb 2010 23:12:12 +0100 From: Tiphaine Turpin User-Agent: Thunderbird 2.0.0.19 (X11/20090216) MIME-Version: 1.0 To: Goswin von Brederlow Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Problem correlating input and output type References: <87fx5mi25n.fsf@frosties.localdomain> <4B65D9D4.4030101@irisa.fr> <87mxzt54lc.fsf@frosties.localdomain> In-Reply-To: <87mxzt54lc.fsf@frosties.localdomain> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; irisa:01 irisa:01 callbacks:01 runtime:01 runtime:01 ocaml:01 ocaml:01 trivial:01 functors:01 recursive:01 typing:01 typing:01 caml-list:01 dependency:01 imperative:01 Goswin von Brederlow a écrit : > Tiphaine Turpin writes: > > >> Goswin von Brederlow a écrit : >> >>> [...] >>> >>> Can anyone think of a way to express this so that the type system keeps >>> track of which callbacks are already connected? >>> >> Runtime checking would be much easier (but still a bit hackish). >> > > But runtime checks will only show the error when the GUI object is > instantiated. Some obscure dialog might not pop up in month. [...] > But how do you translate that into ocaml objects? > > I see two requirements in your problem that are difficult to combine: - static checking by an "ordinary" type system - dynamic connection of objects. First, I believe that it prevents anything imperative (because such typing ignores the execution flow). A functional approach may succeed in some sense, but I don't think that it would be practical. As for the combination with objects, In my (humble) experience with objects in Ocaml, I found that typing even reasonably simple designs is not a trivial task. So, combining that with the earlier hack would quickly become a nightmare. My personal opinion would be to drop the second condition, and make the connection of your objects static. I would try to define the objects as functors, with one module parameter per connection, and connect all that using (possibly recursive) module definitions. I'm curious to know what solutions object-oriented people could propose, in particular with dependency injection. Tiphaine