From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q285C2MF004243 for ; Thu, 8 Mar 2012 06:12:03 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUCACA+WE/ZSMDzjmdsb2JhbABDtSkiAQEBAQkLCQkSBSSCCgEBBAE6PxALISUPAQQNGyETG4doCboDiTiHNgSbEoVQh1o X-IronPort-AV: E=Sophos;i="4.73,550,1325458800"; d="scan'208";a="134947052" Received: from fmmailgate05.web.de ([217.72.192.243]) by mail4-smtp-sop.national.inria.fr with ESMTP; 08 Mar 2012 06:11:57 +0100 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate05.web.de (Postfix) with ESMTP id 4F1FC6AF89B7 for ; Thu, 8 Mar 2012 06:11:57 +0100 (CET) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb002) with ESMTPA (Nemesis) id 0M2dxF-1SOgS93fc5-00sein; Thu, 08 Mar 2012 06:11:57 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1S5Vdq-0006U8-A6; Thu, 08 Mar 2012 06:11:56 +0100 From: Goswin von Brederlow To: Gabriel Scherer Cc: Goswin von Brederlow , Edgar Friendly , caml-list@inria.fr References: <87sjhktqwi.fsf@frosties.localnet> <4F5777F2.2000806@gmail.com> <878vjctlr3.fsf@frosties.localnet> Date: Thu, 08 Mar 2012 06:11:54 +0100 In-Reply-To: (Gabriel Scherer's message of "Wed, 7 Mar 2012 17:58:09 +0100") Message-ID: <877gyv7k2t.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:EZGMTRMJ0y+HXqEr58dzCVNDRNDlrZeqpJwvlEZiaOI +jo+y2DUWn/w+MW3ROxbohSt6jxRHcSLH7/8gFas08m7VuBYWy upQVhkbhP0vFKfi9HhUKThEwiFTCRnBrNKEaF1bSv39fP28GRU WKH2T1a+xnWx9MZv9uCfikdXcWWoUSOLuoyFNhn30tn7OrBcmB ejJeCMvCp/tUqRkSdMOcg== Subject: Re: [Caml-list] Can one implement greedy/inline data structures in ocaml? Gabriel Scherer writes: >> So then you need mutable option types or mutables that you initialize >> with dummy values and then overwrite with the real thing once all >> members of a cycle are created. Or some other trickery to make it >> work. Overall cycles are generally not good. > > I believe the trick you need (either passing a dummy value of your > type, or Obj.magic) is less ugly that your Camlp4 solution for inline > access. > If I really needed absolute performance, I'd use the inline version > just like in C, with mutable fields, but without preprocessor sugar. > Preprocessing could avoid a bit of duplication (corresponding to > manual inlining) on the structure-definition side, but wouldn't > simplify the structure-using code much. How? type task = { mutable all_next : task; mutable all_prev : task; mutable state_next : task; mutable state_prev : tast; ... } Now how do yout write DList.insert, DList.remove, DList.iter, ...? I'm looking for some nice tricks using closures, functors, first class modules or something to make it look pretty and easy to use. I do have an ugly solution but I'm hoping for some fresh idea not based on what I already know is ugly. I can't be the only one that found the need to keep an item in two containers and be able to remove it from both quickly, right? MfG Goswin