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 4B244BB9C for ; Wed, 14 Sep 2005 10:00:54 +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 j8E80rv3025351 for ; Wed, 14 Sep 2005 10:00:54 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA30300 for ; Wed, 14 Sep 2005 10:00:53 +0200 (MET DST) Received: from mxintern.schlund.de (mxintern.kundenserver.de [212.227.126.201]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8E80rip025348 for ; Wed, 14 Sep 2005 10:00:53 +0200 Received: from [172.17.36.11] (helo=schluck.use.schlund.de) by mxintern.kundenserver.de with esmtp (Exim 4.34) id 1EFSCI-0006uz-M8 for caml-list@inria.fr; Wed, 14 Sep 2005 10:00:50 +0200 From: Michael Wohlwend To: caml-list Subject: object question Date: Wed, 14 Sep 2005 10:00:50 +0200 User-Agent: KMail/1.8 X-Face: S)[vu%Bha1d&ej9GfwAq~7C}A,y[B.uS}+D6'hb~xPwsxymw$fnCOaMe<=?utf-8?q?*bnUajSBR=5Fm=3FR=0A=09?=@V3;iX8[A}z`.%pEQ1r7iZhN8#ktTCBQ}&mkx>=RH&l|l6\]NZI@ MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200509141000.50364.micha-1@fantasymail.de> X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Miltered: at concorde with ID 4327D8B5.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4327D8B5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; val:01 mutable:01 stack:01 cheers:01 ...:98 functions:01 define:01 defined:01 unit:03 unit:03 let:03 let:03 allready:07 cast:07 cast: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.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 Hi, I want to make some chained object and an "apply" function on this chain. it might look as this (the functions don't make sense...yet :) ----------------------------------------------- class type tst = object method next: tst method clr: unit method apply: (tst -> unit) -> unit end;; let empty : tst = object(self) method next = self method clr = () method apply fkt = () end;; class test : tst = object(self) val mutable n = empty method clr = () method next = n method apply fkt = fkt (self :> tst) ; self#next#apply fkt (* Line 17 *) end;; let a = new test in a#apply (fun o -> o#clr) ---------------------------------------------------- first question, why do I have to cast self to tst in Line 17? The class test is defined to be of type tst, so self should allready be of type tst. But it works only with the cast. The other question, does this "apply" function use up the stack? Would it be better to define a tail-recursive apply outside the class? cheers Michael