File 1026-erlang-module-doc-fun_to_list-1.patch of Package erlang

From 876b213b8f97cc5c5d101ddc5bbbd33ed7ab5ead Mon Sep 17 00:00:00 2001
From: Kjell Winblad <kjellwinblad@gmail.com>
Date: Thu, 3 Sep 2020 09:33:07 +0200
Subject: [PATCH 16/39] erlang module doc: fun_to_list/1

Describe what this function returns more precisely.
---
 erts/doc/src/erlang.xml       | 39 +++++++++++++++++++++++++++++++++--
 erts/preloaded/src/erlang.erl |  5 +++--
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml
index 004ac3a1f6..35a9543023 100644
--- a/erts/doc/src/erlang.xml
+++ b/erts/doc/src/erlang.xml
@@ -2033,8 +2033,43 @@ true</pre>
       <name name="fun_to_list" arity="1"/>
       <fsummary>Text representation of a fun.</fsummary>
       <desc>
-        <p>Returns a string corresponding to the text
-          representation of <c><anno>Fun</anno></c>.</p>
+        <warning>
+          <p>This function is <em>not</em> guaranteed to work as described here
+          when <c><anno>Fun</anno></c> was created while executing
+          uncompiled code (uncompiled escripts, the Erlang shell, and
+          other code executed by the <seealso
+          marker="stdlib:erl_eval"><c>erl_eval</c> module</seealso>).</p>
+        </warning>
+                <p>Returns <c><anno>String</anno></c> that represents the code
+        that created <c><anno>Fun</anno></c>.</p>
+        <warning>
+        <p>Generally, one can not use this function to check if two
+        funs are equal as this function does not take the fun's
+        environment into account. See <seealso
+        marker="#fun_info/1"><c>erlang:fun_info/1</c></seealso> for how
+        to get the environment of a fun.</p>
+        </warning>
+        <note>
+          <p><c><anno>String</anno></c> has the following form, if
+          <c><anno>Fun</anno></c> was created by an expression of the
+          form <c>fun ModuleName:FuncName/Arity</c>:</p>
+
+          <p><c>"fun ModuleName:FuncName/Arity"</c>,</p>
+
+          <p>and <c><anno>String</anno></c> has the following form, if
+          <c><anno>Fun</anno></c> was created by a <seealso
+          marker="system/reference_manual:expressions#fun-expressions">fun
+          expression</seealso>:</p>
+
+          <p><c>"#Fun&lt;M.I.U>"</c>, where M, I and U correspond to
+          the values named <c>module</c>, <c>index</c> and <c>uniq</c>
+          in the result of <seealso
+          marker="#fun_info/1"><c>erlang:fun_info(Fun)</c></seealso>.</p>
+
+          <p>The output of <c>fun_to_list/1</c> can differ between
+          Erlang implementations and can change in future
+          versions.</p>
+        </note>
       </desc>
     </func>
 
diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl
index 7b054b84b7..66695f784b 100644
--- a/erts/preloaded/src/erlang.erl
+++ b/erts/preloaded/src/erlang.erl
@@ -934,8 +934,9 @@ fun_info_mfa(_Fun) ->
     erlang:nif_error(undefined).
 
 %% fun_to_list/1
--spec erlang:fun_to_list(Fun) -> string() when
-      Fun :: function().
+-spec erlang:fun_to_list(Fun) -> String when
+      Fun :: function(),
+      String :: string().
 fun_to_list(_Fun) ->
     erlang:nif_error(undefined).
 
-- 
2.26.2

openSUSE Build Service is sponsored by