# Why are blankspaces allowed between Module and function?

**URL:** <https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794>\
**Category:** Questions\
**Tags:** compiler, language-implementation\
**Created:** [December 24, 2019, 7:40pm UTC](https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794 "2019-12-24T19:40:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluegene](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/b/34f0e0/32.png) [@bluegene](https://forum.elixirforum.com/u/bluegene)\
**Post date:** [December 24, 2019, 7:40pm UTC](https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794/1 "2019-12-24T19:40:01Z")

</div>

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,

```elixir
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:

```elixir
def handle_call(request, _caller, state) do
    {:reply, request. state}
end

```

When invoking a GenServer call, I got,

```elixir
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?

---

<div class="post-metadata">

**Author:** ![lpil](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lpil/32/17492_2.png) [@lpil](https://forum.elixirforum.com/u/lpil)\
**Post date:** [December 24, 2019, 8:28pm UTC](https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794/2 "2019-12-24T20:28:12Z")

</div>

This is quite normal behaviour for a parser. With most parser technologies it is considerably more difficult to add this kind of whitespace sensitivity (and it would disallow splitting map access chains over multiple lines).

Try adding whitespace in random places in various languages, I think you’ll be surprised where it’s allowed. 🙂

---

<div class="post-metadata">

**Author:** ![hauleth](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/32/18942_2.png) [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Post date:** [December 27, 2019, 1:30pm UTC](https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794/3 "2019-12-27T13:30:00Z")

</div>

It just makes parser simpler, as it tokenise it to `{{:., [], [IO, :puts]}, [], ["hello"]}` (simplified). As you can see `.` is independent operator, lust like `+` or `|>`. Disallowing spaces around only one operator just for sake of I-have-no-idea-what would be pointless.

---

<div class="post-metadata">

**Author:** ![Nicd](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nicd/32/2357_2.png) [@Nicd](https://forum.elixirforum.com/u/Nicd)\
**Post date:** [December 27, 2019, 2:24pm UTC](https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794/4 "2019-12-27T14:24:37Z")

</div>

This reminds me of the PHP “downto” operator `-->` 🙂:

```php
$a = 100;
while ($a --> 0) { echo $a, PHP_EOL; }

```

---

<div class="post-metadata">

**Author:** ![hauleth](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/32/18942_2.png) [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Post date:** [December 27, 2019, 2:41pm UTC](https://forum.elixirforum.com/t/why-are-blankspaces-allowed-between-module-and-function/27794/5 "2019-12-27T14:41:39Z")

</div>

It came out from C, I do not know if there is any previous example of `--` operator.
