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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 23EF0BB84 for ; Mon, 8 May 2006 23:29:47 +0200 (CEST) Received: from lynndie.uscs.susx.ac.uk (lynndie.uscs.susx.ac.uk [139.184.14.87]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k48LTkXd017490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 8 May 2006 23:29:46 +0200 Received: from ras75-3-82-225-164-165.fbx.proxad.net ([82.225.164.165]:35028) by lynndie.uscs.susx.ac.uk:587 with esmtpsa (TLSv1:EXP1024-RC4-SHA:128) (Exim 4.43) id IYYUJE-000LS2-K6 for caml-list@yquem.inria.fr; Mon, 08 May 2006 22:33:14 +0100 From: David Teller To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OO design Date: Mon, 8 May 2006 23:29:36 +0200 User-Agent: KMail/1.9.1 References: <53c655920605050235k64e70333je8df813239ea3c53@mail.gmail.com> <20060508.121743.65190532.garrigue@math.nagoya-u.ac.jp> In-Reply-To: <20060508.121743.65190532.garrigue@math.nagoya-u.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200605082329.36911.David.Teller@ens-lyon.org> Sender: dot20@sussex.ac.uk X-Sussex: true X-Miltered: at concorde with ID 445FB84A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ens-lyon:01 ocaml:01 subtyping:01 ocaml:01 rewriting:01 statically:01 model:01 subclassing:01 run-time:01 cheers:01 2006:98 wrote:01 caml-list:01 jacques:01 checking:02 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 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