Meaning of the prefix "fun"

I am aware of the Fun Expressions.

I do not know the necessity/meaning of the prefix “fun” while calling a function as shown in the following example code. Please clarify.

-module(my_sort).
-export([sort/1]).
-include_lib("eunit/include/eunit.hrl").

-spec sort([T]) -> [T].
sort([]) -> [];
sort([P|Xs]) ->
  sort([X || X <- Xs, X < P]) ++ [P] ++ sort([X || X <- Xs, P < X]).

sort2_test_() ->
  [ {"testcase with 4 paras", fun test_four/0},
    {"testcase with 5 paras", fun test_five/0}].

test_four() ->
  [?_assertEqual([1,2,3,4], sort([3,1,4,2]))].
test_five() ->
  [?_assertEqual([1,2,3,4,5], sort([3,1,4,2,5]))].
2 Likes

That expression is not a function call, it is function reference instead.

4 Likes