From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA15350 for caml-redistribution; Wed, 13 Jan 1999 12:24:32 +0100 (MET) 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 JAA10273 for ; Wed, 13 Jan 1999 09:47:52 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id JAA04700 for ; Wed, 13 Jan 1999 09:47:49 +0100 (MET) Received: from localhost (safran.kurims.kyoto-u.ac.jp [130.54.16.91]) by kurims.kurims.kyoto-u.ac.jp (8.9.1a/3.7W) with ESMTP id RAA19534 for ; Wed, 13 Jan 1999 17:47:40 +0900 (JST) To: caml-list@pauillac.inria.fr Subject: Re: Map is not tail recursive In-Reply-To: Your message of "Mon, 11 Jan 1999 11:51:25 -0700" <001101be3d93$66516610$210148bf@dylan> References: <001101be3d93$66516610$210148bf@dylan> X-Mailer: Mew version 1.93 on Emacs 20.3 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <19990113174708X.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 13 Jan 1999 17:47:08 +0900 From: Jacques GARRIGUE X-Dispatcher: imput version 980905(IM100) Content-Transfer-Encoding: 7bit Sender: weis From: "David McClain" > Juan got me thinking about this problem... So here is a solution: > > external rplacd : 'a list -> 'a list -> unit = "rplacd" > > -- and the external C code is > > value rplacd(value cell, value item) > { > Store_field(cell,1,item); > return Val_unit; > } While this is undocumented, there is a slightly simpler way to define rplacd, wihout using C. This should be faster in most cases (particularly if you inline it). let rplacd (cell : 'a list) (item : 'a) = Obj.set_field (Obj.repr cell) 1 (Obj.repr item) As for using the null pointer to have more efficient representations in data-structures, this is theoretically possible (and I believe that Xavier Leroy had an implementation with it), but this is not in the current version of ocaml. Jacques --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG