Recently after spending an hour debugging/staring at a code, I found out that one or more blankspaces are allowed when invoking a function. For example,
iex(7)> IO. puts "hello"
hello
:ok
iex(8)> IO. puts("hello")
hello
:ok
I personally think this will introduce bugs. Here’s one instance where I ran into a problem when I mistakenly typed a period instead of a comma:
def handle_call(request, _caller, state) do
{:reply, request. state}
end
When invoking a GenServer call, I got,
14:19:30.744 [error] GenServer :my_registry terminating
** (UndefinedFunctionError) function :some_request.state/0 is undefined (module :some_request is not available)
:some_request.state()
echo_gen_server.ex:13: EchoGenServer.handle_call/3
(stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:690: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
What is the reasoning behind allowing blankspaces between Module and function invocation? Shouldn’t the compiler flag this and reported as error?