From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id AC3BFBC69; Thu, 3 May 2007 03:30:59 +0200 (CEST) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l431Uv3f015821; Thu, 3 May 2007 03:30:58 +0200 X-IronPort-AV: E=Sophos;i="4.14,482,1170595800"; d="scan'208";a="122627421" Received: from ppp8-148.lns1.syd7.internode.on.net (HELO [192.168.1.201]) ([59.167.8.148]) by ipmail01.adl2.internode.on.net with ESMTP; 03 May 2007 11:00:55 +0930 Subject: Re: [Caml-list] menhir From: skaller To: Francois.Pottier@inria.fr Cc: caml-list@inria.fr In-Reply-To: <20070502183549.GB17473@yquem.inria.fr> References: <20070428165058.GA31584@yquem.inria.fr> <1177821783.25394.37.camel@rosella.wigram> <20070501155705.GA29617@yquem.inria.fr> <1178039464.8967.10.camel@rosella.wigram> <20070501173409.GB7308@yquem.inria.fr> <1178062950.8967.39.camel@rosella.wigram> <20070502053815.GA726@yquem.inria.fr> <1178095304.13660.71.camel@rosella.wigram> <20070502123058.GC21560@yquem.inria.fr> <1178123357.6486.49.camel@rosella.wigram> <20070502183549.GB17473@yquem.inria.fr> Content-Type: text/plain Date: Thu, 03 May 2007 11:30:48 +1000 Message-Id: <1178155848.7026.27.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46393B51.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 lexbuf:01 parser:01 mutable:01 lexbuf:01 functor:01 functor:01 sourceforge:01 wrote:01 wrote:01 caml-list:01 functions:01 pottier:01 closure:01 argument:02 On Wed, 2007-05-02 at 20:35 +0200, Francois Pottier wrote: > On Thu, May 03, 2007 at 02:29:17AM +1000, skaller wrote: > > Yes, but you cannot write functions that take a state argument > > because lexbuf is a fixed data type and there's no where to > > add in any user state data. > > But my point is that you never need to pass a state argument to a parser > function. Instead, you can just have the function capture the address of the > (mutable) state in its closure. And mine is that you can't do that because the function is generated with a fixed signature, whose only state data is the lexbuf. Joel pointed out this isn't so, if you use a functor and construct it locally, then a 'global' variable of the functor is actually localised: I admit I didn't think of local dynamic instantiation. -- John Skaller Felix, successor to C++: http://felix.sf.net