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 86F2F7F7C2 for ; Tue, 4 Feb 2014 13:33:59 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.17.9; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.17.9; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.17.9 as permitted sender) identity=helo; client-ip=212.227.17.9; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQCAJTd8FLU4xEJlGdsb2JhbABZg0S+cIEKFg4BAQEBBwsLCRIqgiYBBVUkEAtGVwYTCYgACc4qF4kyhR0mB4IvD4F6BI8RhTGKKwWPBw X-IPAS-Result: AgQCAJTd8FLU4xEJlGdsb2JhbABZg0S+cIEKFg4BAQEBBwsLCRIqgiYBBVUkEAtGVwYTCYgACc4qF4kyhR0mB4IvD4F6BI8RhTGKKwWPBw X-IronPort-AV: E=Sophos;i="4.95,779,1384297200"; d="asc'?scan'208";a="56794396" Received: from moutng.kundenserver.de ([212.227.17.9]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 Feb 2014 13:33:59 +0100 Received: from office1.lan.sumadev.de (dslb-088-069-140-074.pools.arcor-ip.net [88.69.140.74]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0MMWL8-1WA56J1nQM-008HcT; Tue, 04 Feb 2014 13:33:57 +0100 Received: from [192.168.0.195] (546BEFE6.cm-12-4d.dynamic.ziggo.nl [84.107.239.230]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id CA449C00D3; Tue, 4 Feb 2014 13:33:56 +0100 (CET) Message-ID: <1391517231.19912.10.camel@e130> From: Gerd Stolpmann To: Francois Berenger Cc: caml-list@inria.fr Date: Tue, 04 Feb 2014 13:33:51 +0100 In-Reply-To: <52F0455E.5040806@riken.jp> References: <52F0455E.5040806@riken.jp> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-jjFlnA3mswMJrNNfs3LY" X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Provags-ID: V02:K0:wjOjWYM6HFpxmYLFZ4i4nYviPYdXB+KBDw8+OH0HygB +NH+kE0bDMJzlO4ataNr2VaWMz4079msstsbBZ6FypZC6iXY16 lJJ2CtO5Qm4uKqH1tQEl90DxTZaVFqMq7oncWyd65FYfJIrMfP OOGSgiagu8Vilw2ZE+Mr5NAcpMVu6UiQq91VNZyvFJE0bsYUuZ ZZfsJHTm9FrKo/qrVyGktnY/4IqACrW4X+mq1Pr2IZ7G9n9lpj xSrgItJLMOHEIBhQUsXBcZdukU/gPBkbibktlcn6N4Zf78C5Rq k1sJu7PsJPb0DBE/FaC660sj/bEpG5KChgwOBMFcgmv9qumsxe B6GiO8aJqG7QYuE79pMn0Z38XpRQUZLLbKsQt/95c Subject: Re: [Caml-list] is there a runtime cost for this --=-jjFlnA3mswMJrNNfs3LY Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable Am Dienstag, den 04.02.2014, 10:41 +0900 schrieb Francois Berenger: > Hello, >=20 > In a .ml file I'd like to write something like this > in order to factorize some code: >=20 > let f x y z =3D [...] some code [...] >=20 > module Something =3D struct > let g =3D f > end >=20 > module Something_else =3D struct > let h =3D f > end >=20 > Is calling Something.g or Something_else.h as efficient > as calling f directly? This is the same: For the calls of g and h ocamlopt generates code that actually calls f. Even the eta-expanded version is cheap: module Something =3D struct let g2 x y z =3D f x y z end The code for g2 consists just of a jump to the body of f. (And normally the inlining feature of ocamlopt even changes calls to g into calls to f.) Generally, ocamlopt is very good at function calls, no matter which variant (direct or indirect call, with or without curried arguments, inside an inner module or a functor). Don't put too much effort into optimizing this by hand. Gerd >=20 > --=20 > Best regards, > Francois Berenger. >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-jjFlnA3mswMJrNNfs3LY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAABAgAGBQJS8N4vAAoJEAaM4b9ZLB5TeiIH/RBW8SnBOFOF4MkwRBrS6kYe DymCUAsk2U8pL9T+vt4ouro9sVbso6zyIyMM8AL9Dont3B4eazpQVtZAJ56SX91B h1+jfra6xbyYNO97ER/HkBAXHynerHD39Wrykj7AsGHWRXkm0K8KZx6Cdk6n/AGz np1lr9a8fiLkx1QH4vcoPaUnRxsmY9eCgVHgXg5ecxwNBK7fzCJ6GLwgy5ZK5k4W PvvioWjvYhC+huOA7pmyLEa/A1lyHS0pss32uUd3+sTEbaGOlmh9DgI5c9Jvv8OX /ZYOXaYxpxR0enPpgwEjcdXNWKyWpv9bsjEVnIDYN5p4wAfKpYnOpCzwCCMsu1s= =QJV5 -----END PGP SIGNATURE----- --=-jjFlnA3mswMJrNNfs3LY--