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=AWL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id DA330BC69 for ; Wed, 5 Dec 2007 05:16:31 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CABC1VUfUnw6Flmdsb2JhbACCOI0dAgEBBwQGIgeBFA X-IronPort-AV: E=Sophos;i="4.23,252,1194217200"; d="scan'208";a="19990570" Received: from pih-relay06.plus.net ([212.159.14.133]) by mail4-smtp-sop.national.inria.fr with ESMTP; 05 Dec 2007 05:16:31 +0100 Received: from [80.229.56.224] (helo=beast.local) by pih-relay06.plus.net with esmtp (Exim) id 1IzlgU-0005kO-7Q for caml-list@yquem.inria.fr; Wed, 05 Dec 2007 04:16:30 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Disabling the OCaml garbage collector Date: Wed, 5 Dec 2007 04:07:09 +0000 User-Agent: KMail/1.9.5 References: <474DC8DA.8070806@functionality.de> <3DA0E7CA-2511-4282-89D1-8EB42876EC18@rice.edu> In-Reply-To: <3DA0E7CA-2511-4282-89D1-8EB42876EC18@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712050407.09310.jon@ffconsultancy.com> X-Spam: no; 0.00; ocaml:01 followup:01 ocaml:01 recursive:01 recursive:01 frog:98 garbage:01 wrote:01 stack:01 caml-list:01 functions:01 tail:01 int:01 int:01 caml:02 On Tuesday 04 December 2007 20:14, Raj Bandyopadhyay wrote: > Dear all, > > As a followup to this discussion, I have been trying to understand > the OCaml/C interface better. Here's a very small program that I've > been trying to get to work. It's a mutually recursive function, one > part in C and the other in OCaml. > > (* (* Implement this in C *) > let factC g n = if n=0 then [] else ("C",n)::(g (n-1));; > *) > > external factC: (int ->(string * int) list) -> int -> ((string * int) > list)= "caml_factC" > let factO g n = if n=0 then [] else ("OCaml",n)::(g (n-1));; Could it just be segfaulting because you've overflowed the stack? Try tail recursive functions, e.g. CPS. I would love to see this working because I never managed to get this kind of stuff to work before. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e