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 D6042BB83 for ; Fri, 5 May 2006 11:35:40 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k459ZeN3002670 for ; Fri, 5 May 2006 11:35:40 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA25552 for ; Fri, 5 May 2006 11:35:39 +0200 (MET DST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k459Zdir014154 for ; Fri, 5 May 2006 11:35:39 +0200 Received: by ug-out-1314.google.com with SMTP id e2so246044ugf for ; Fri, 05 May 2006 02:35:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=K3VrLadp/aakNUWvF7Af5cVc696qyWvBEyLyCVaj9/6ezGuv3OlPDjG0scQEN3rSXnFIvdD/J4kbwCZ0hLFU52AIXeL7E5uYT6gk4F81LUA3V4/OxG6xUtCNKf1rPa6vaKXT10aBvj3oOOYBkIc1yLd0c9Ii7Ma1/e9Uib73QtM= Received: by 10.78.45.13 with SMTP id s13mr239020hus; Fri, 05 May 2006 02:35:38 -0700 (PDT) Received: by 10.78.16.10 with HTTP; Fri, 5 May 2006 02:35:38 -0700 (PDT) Message-ID: <53c655920605050235k64e70333je8df813239ea3c53@mail.gmail.com> Date: Fri, 5 May 2006 11:35:38 +0200 From: "David Baelde" Reply-To: david.baelde@ens-lyon.org To: Ocaml Subject: OO design MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-j-chkmail-Score: MSGID : 445B1C6B.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 445B1C6C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 445B1C6B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; overriding:01 ocaml:01 behaviour:01 functions:01 define:01 defined:02 seems:03 complex:04 derived:04 interface:05 i'd:05 irrelevant:06 respectively:07 classes:07 anybody:07 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=RCVD_BY_IP autolearn=disabled version=3.0.3 Hi, I'm no OO guru, so my question may be irrelevant, or there just might not be an answer, which wouldn't hurt.. Let's say that I have a base class, with some kind of activation procedure: anybody wanting to use the class must call #enter before, and then call #leave for releasing. Internally, the methods #do_enter and #do_leave are called respectively at the first #enter and last #leave. Nobody should call the #do_* directly, and I'd also like to make sure the #enter and #leave are never overriden, since their behaviour is important and actually much more complex than what I said. I could just rely on the user who derives my base class, but let's see what we can do. First the #do_* should be made private, so they can be defined in the derived classes, but never called from the outside. To avoid the overriding of #enter and #leave the only solution seems to make them normal functions instead of methods. But then how could #enter call #do_enter ? I tried to first define the class with public #enter and make that method private in the interface, but OCaml told me that was impossible. I'm just curious if anybody has an opinion/idea about that. -- David