[erlang-patches] [PATCH] Fix lists:foreach/2's documented spec
Mon Oct 11 15:04:18 CEST 2010
Björn Gustavsson wrote:
> On Sun, Oct 10, 2010 at 7:02 PM, Tuncer Ayaz <> wrote:
>> lib/stdlib/doc/src/lists.xml | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>> diff --git a/lib/stdlib/doc/src/lists.xml b/lib/stdlib/doc/src/lists.xml
>> index 92c4eb4..0cf88fe 100644
>> --- a/lib/stdlib/doc/src/lists.xml
>> +++ b/lib/stdlib/doc/src/lists.xml
>> @@ -297,10 +297,10 @@ flatmap(Fun, List1) ->
>> - <name>foreach(Fun, List) -> void()</name>
>> + <name>foreach(Fun, List) -> ok</name>
>> <fsummary>Apply a function to each element of a list</fsummary>
>> - <v>Fun = fun(Elem) -> void()</v>
>> + <v>Fun = fun(Elem) -> term()</v>
>> <v> Elem = term()</v>
>> <v>List = [term()]</v>
> void() is a convention used in the documentation to mean
> that the function has no useful return value and should be
> ignored. It is used in many places in the documentation.
> git grep 'void()' | grep '[.]xml'
Convention or not, the fact remains that a void() type does not exist in
Erlang. The problem is that even if one is careful enough not to match
against the result of the lists:foreach/2 call, the return from this
function can propagate higher up in the function call chain.
gazonk = foo2(...), % this one will fail here
It would be a much better world if all void() functions were made to
return some consistent value such as 'ok'.
More information about the erlang-patches