[erlang-questions] Compiler to warn on used underscore-variables

Zoltan Lajos Kis <>
Thu Jan 7 08:40:28 CET 2010


> On 7/01/10 6:32 AM, mog wrote:
>> On Wed, Jan 06, 2010 at 02:23:08PM +0100, Tony Rogvall wrote:
>>
>>>> I'm simply proposing that if the compiler sees code like:
>>>>
>>>> measure_secs(Fun) ->
>>>>  {_M, S1, _U} = erlang:now(),
>>>>  Fun(),
>>>>  {_M, S2, _U} = erlang:now(),
>>>>  S2 - S1.
>>>>
>>>> to output something like: "Warning: variable '_U' is not unused".
>>>>
>>>> Zoltan.
>>>>
>>>>
>>>>
>>> +1
>>>
>> ++
>> cant tell you how many times i have bit this one as well.
>>
>>
> For what it's worth, I also support this idea.
>
> (Actually, I was astonished to find that _X was not treated exactly like
> _, so that would be my preferred solution. However, issuing the "not
> unused" warning is much better than what happens now.)
>
> Sam.
>

Well, this behavior has been clearly documented :)
http://erlang.org/doc/reference_manual/expressions.html#id2269867



More information about the erlang-questions mailing list