From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 203247EE51 for ; Wed, 10 Apr 2013 18:15:32 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of marek@xivilization.net) identity=pra; client-ip=178.63.18.39; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="marek@xivilization.net"; x-sender="marek@xivilization.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of marek@xivilization.net designates 178.63.18.39 as permitted sender) identity=mailfrom; client-ip=178.63.18.39; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="marek@xivilization.net"; x-sender="marek@xivilization.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@coaxial.xivilization.net) identity=helo; client-ip=178.63.18.39; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="marek@xivilization.net"; x-sender="postmaster@coaxial.xivilization.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgcFABePZVGyPxIn/2dsb2JhbABQgwbCdRZ0gmAGAQE4OzROiCurSoQ7AQV9jhkGkl6XApEPgw0 X-IPAS-Result: AgcFABePZVGyPxIn/2dsb2JhbABQgwbCdRZ0gmAGAQE4OzROiCurSoQ7AQV9jhkGkl6XApEPgw0 X-IronPort-AV: E=Sophos;i="4.87,447,1363129200"; d="scan'208";a="12690834" Received: from coaxial.xivilization.net ([178.63.18.39]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 10 Apr 2013 18:15:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xivilization.net; s=xiv; h=Content-Transfer-Encoding:Content-Type:Mime-Version:Message-ID:Subject:To:From:Date; bh=1a5ArXTeoFhR2bufyl2+uSMR/FNYz9N3HkZvttXP/qk=; b=YqPVFh4vyygQcqOf1x6BZmlGLBj8geaqyJTf4NSiz+NpSqMRIm9DzNt3rp3HbloDsk+GDAMM3Jh1TdssLTkezO0PRV4OdHfl+fmHfir6KWYHcHshVUeANMmBHZhsnxk6; Received: from ppp-188-174-189-75.dynamic.mnet-online.de ([188.174.189.75] helo=localhost.localdomain) by coaxial.xivilization.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UPxgI-0005yO-IU for caml-list@inria.fr; Wed, 10 Apr 2013 18:15:30 +0200 Date: Wed, 10 Apr 2013 18:15:26 +0200 From: Marek Kubica To: Caml List Message-ID: <20130410181526.2597c7a4@xivilization.net> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.17; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Caml-list] OCaml C macros, what do they do? Hi, I've been using the OCaml C API lately with quite some success (after I realized that the GC causes everything to crash and fixing a lot of stuff). While things work now quite well, I'd like to know what *exactly* the macros are for, since sometimes I can leave them out without any ill effect. So, here's my insights. If anyone of you could point out what is correct and what is not, I'd be grateful: - CAMLparam1(foo), notifies the GC that foo is used in this function and not to be collected. - CAMLlocal1(foo), creates a local variable foo. This is only required if I want to bind some "value" type to a variable name. Not required if I immediately return it. - CAMLreturn(foo) returns a foo value and tells the GC that everything declared by CAMLparam will not be used anymore and could be collected. - CAMLprim defines a function as "primitive" according to the documentation. I have no idea what that means. The example in the manual, section 19.6 does not use CAMLprim to start with. regards, Marek