[erlang-questions] Underscore prefixes

Dan Gudmundsson <>
Fri Apr 18 08:31:32 CEST 2008

My guess is debugging:

   _Result = module:function(X),
  io:format("DBG: ~p ~n", [_Result]),
  {response, ok}.

Than you can delete the debug io:format.

Matthew Dempsky wrote:
> On Thu, Apr 17, 2008 at 7:13 PM, Vik Olliver <> wrote:
>> Underscores before a variable indicate it's basically optional, right?
> It simply tells the compiler not to issue a warning if the variable is
> not otherwise used.
>>  So why would someone do:
>>  _Result = module:function(X),
>>  {response, ok}.
>>  in their code?
> Style maybe.  When matching elements of a tuple, I'll often still
> write "_Foo" and "_Bar" (but actually meaningful names) even if I
> don't need those elements in case I later need to change the code and
> it saves me a little bit of time looking up what the other elements
> are again.
> This particular case though, it's kinda silly.  Obviously the return
> value of a function is its result. :-)
> _______________________________________________
> erlang-questions mailing list
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list