From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA05927; Fri, 27 Jun 2003 10:34:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA06280 for ; Fri, 27 Jun 2003 10:34:13 +0200 (MET DST) Received: from mx-serv.inrialpes.fr (mx-serv.inrialpes.fr [194.199.18.100]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5R8YCj07087 for ; Fri, 27 Jun 2003 10:34:12 +0200 (MET DST) Received: from imap-serv.inrialpes.fr (imap-serv.inrialpes.fr [194.199.18.72]) by mx-serv.inrialpes.fr (8.12.8/8.12.8) with ESMTP id h5R8Y7Yh023706 for ; Fri, 27 Jun 2003 10:34:07 +0200 (MEST) Received: from ORION (orion.inrialpes.fr [194.199.21.113]) by imap-serv.inrialpes.fr (8.11.6/8.11.3/ImagV2) with SMTP id h5R8Y7A18045 for ; Fri, 27 Jun 2003 10:34:07 +0200 (MEST) Message-ID: <015e01c33c86$e06b79d0$7115c7c2@inrialpes.fr> From: "Jean-Baptiste Rouquier" To: References: <003001c33c17$343a0d80$355afac1@zofo> <54997465.20030627092459@kittown.com> Subject: Re: [Caml-list] interfacing C and OCaml Date: Fri, 27 Jun 2003 10:31:44 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: McAfee uvscan 4241 RBL+ ORBS Found to be clean X-Spam: no; 0.00; inrialpes:01 caml-list:01 interfacing:01 camlprim:01 buffer:01 val:01 foo:01 camlparam:01 camlreturn:01 curses:01 mli:01 initscr:01 ocaml:01 external:03 unit:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > JBR> 1. Should I use > JBR> CAMLprim value input(value channel, value buffer, value offset, value > JBR> length) > JBR> { > JBR> return Val_long (...); > JBR> } > > Yes. This function can be called from other C function or from OCaml. > > JBR> as in 18.1.2 in the manual, or > > JBR> void foo (value v1, value v2, value v3) > JBR> { > JBR> CAMLparam3 (v1, v2, v3); > JBR> ... > JBR> CAMLreturn0; > JBR> } > > This if for functions called from C only. Not suitable for use from > OCaml directly. > > Should be specified in the manual, I believe, but I've got no response > in the list to my comment on this. I hope it will be in the manual for > the OCaml 3.07. > Strange ! The complete example given in 18.6 contains : curses.mli : external initscr: unit -> window = "curses_initscr" curses.c ("curses.o" in the manual) : value curses_initscr(value unit) { CAMLparam1 (unit); CAMLreturn ((value) initscr()); } curses.ml : open Curses let main_window = initscr () in So functions using CAMLparam and CAMLreturn are called from OCaml directly. Or am I completely wrong ? I'm worried about the GC (for now, my code seems to run correctly, but use perhaps to much memory). Thanks, JBR ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners