There is a general rule for designating any unused variables with _ in Elixir. This prevents everything related to this variable.
However, I noticed a commonly used underscore prefix pattern to indicate an ignored argument in the form of _tail (with the intention of indicating a hint about which variable will be).
This is recommended by the language with a warning in the shell if you try to access _tail :
warning: after installation, the underlined variable "_tail" is used. The underlined underline means that the value of the variable should be ignored. Rename this variable if necessary to remove the underline.
But here is the catch; _tail has a variable associated with it, whereas when using only _ it is not.
Does this mean that there is a performance limitation when naming ignored variables with anything other than _ ? Or does Elixir still bind _ backstage and just a mistake on any access attempt?
Edit: It seems that the Erlang compiler specifically optimizes this case to handle _* as _ and therefore there is no overhead, source: http://erlang.org/doc/efficiency_guide/myths.html
elixir
whitfin
source share