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 409897EE7D for ; Mon, 1 Jun 2015 18:46:44 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.13,534,1427752800"; d="scan'208";a="161292399" Received: from meleze.ens.fr (HELO [129.199.99.114]) ([129.199.99.114]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 01 Jun 2015 18:46:44 +0200 Message-ID: <556C8C74.5030809@inria.fr> Date: Mon, 01 Jun 2015 18:46:44 +0200 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <556C4512.2050002@free.fr> <556C89F3.3000206@free.fr> In-Reply-To: <556C89F3.3000206@free.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] getting the name of a function from its body On 06/01/2015 06:36 PM, Gustave Nimant wrote: > On 01/06/2015 13:46, Fabrice Le Fessant wrote: >> Recent versions of OCaml provide "__LOC__", "__FILE__", "__LINE__", >> "__MODULE__" and "__POS__" primitives that can be used to display >> precise error messages. >> >> --Fabrice > Thank you for this information I was not aware of. > It seems that the functions described in > http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html > do not answer my question : > "how to get the name of the current function ?" It is currently not possible. There is no __FUNCTION__ like you have in C. I was also quite interested by this feature a long time ago. For loggers it is quite useful. I cannot find the thread back, I don't know where to search the archives of caml-list. Gabriel Scherer mentioned there is not always a function name since they can be inlined by the compiler, if I remember correctly. > Do I miss something ? > > Gustave > -- Regards, Francois.