From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 51788BB84 for ; Mon, 8 May 2006 23:36:18 +0200 (CEST) Received: from hugh.cs.washington.edu (hugh.cs.washington.edu [128.208.2.43]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k48LaFxY011040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 8 May 2006 23:36:17 +0200 Received: from [128.208.2.33] (gerald.cs.washington.edu [128.208.2.33]) by hugh.cs.washington.edu (8.13.6/8.13.5/1.5) with ESMTP id k48LaCJb007673; Mon, 8 May 2006 14:36:12 -0700 (envelope-from djg@cs.washington.edu) Message-ID: <445FB9C7.4040703@cs.washington.edu> Date: Mon, 08 May 2006 14:36:07 -0700 From: Dan Grossman User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Teller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OO design References: <53c655920605050235k64e70333je8df813239ea3c53@mail.gmail.com> <20060508.121743.65190532.garrigue@math.nagoya-u.ac.jp> <200605082329.36911.David.Teller@ens-lyon.org> In-Reply-To: <200605082329.36911.David.Teller@ens-lyon.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 445FB9CF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 subtyping:01 ocaml:01 rewriting:01 statically:01 model:01 subclassing:01 run-time:01 cheers:01 beginner's:01 beginners:01 bug:01 2006:98 wrote:01 wrote:01 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 Phantom types are a programming idiom that can often pull off this sort of thing. --Dan David Teller wrote: > On Monday 08 May 2006 05:17, Jacques Garrigue wrote: > >>I would be tempted to say: there is no answer. >>Ocaml objects are not about enforcing protocols, but about allowing >>inheritance and structural subtyping, and this does not fit well with >>your problem. > > > Which brings us to a question : how do you enforce protocols in OCaml ? > > Say, is there a "good" way of rewriting file-related operations so that, say, > ProtocolUnix.read and ProtocolUnix.write *statically* only accept opened > files, and in addition, ProtocolUnix.write only accepts files which have been > opened with write priviledges ? > > I mean, there are manners of checking this with, say, model checking tools. In > the specific case of file management, I guess we can do it with a little bit > of simple subclassing, but I assume there's a large run-time penalty for this > extra bit of checking, due to the management of objects by OCaml. Has anyone > attempted to determine how well this scales up ? Or explored other options ? > > Cheers, > David > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs