From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA09943 for caml-redistribution; Fri, 17 Sep 1999 13:12:12 +0200 (MET DST) 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 PAA25910 for ; Wed, 15 Sep 1999 15:30:32 +0200 (MET DST) Received: from isil.maya.com (isil.maya.com [192.70.254.5]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id PAA14522 for ; Wed, 15 Sep 1999 15:30:30 +0200 (MET DST) Received: (from prevost@localhost) by isil.maya.com (8.9.3/8.9.3) id JAA25996; Wed, 15 Sep 1999 09:33:33 -0400 Sender: weis To: Steve Stevenson Cc: caml-list@inria.fr Subject: Re: Imperative list operations References: <14302.41638.913957.615588@merlin.cs.clemson.edu> From: John Prevost Date: 15 Sep 1999 09:33:33 -0400 In-Reply-To: Steve Stevenson's message of "Tue, 14 Sep 1999 15:36:18 -0400 (EDT)" Message-ID: User-Agent: Gnus/5.070096 (Pterodactyl Gnus v0.96) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Steve Stevenson writes: > I need a double-ended queue implementation. {...imperative...} > I've tried all the naïve type declarations --- all of which > don't seem to work. I've tried the age old tricks. What am I not > understanding? or doing right? I'm not fussy: tuples, records or > objects are fine. It'd help to know what you've tried. The following work for me: type 'a dlist_node = | Nil | Node of 'a dlist_node ref * 'a * 'a dlist_node ref Or better: type 'a dlist_node = { mutable dlist_prev : 'a dlist_node option; dlist_val : 'a; mutable dlist_next : 'a dlist_node option } Note that in the first case, you need to use value constructors, since: type 'a dlist_node = 'a dlist_node option ref * 'a * 'a dlist_node option ref is recursive, and O'Caml doesn't allow type aliases (as opposed to union types or record types, which "create" new types) to be recursive. John.