lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

And if one (= Lua authors, that is :) made it so that a *read* of '_' causes an error (instead of giving 'nil') everything would be fine. If someone really used that value somewhere, it'd get trapped right away.


18.9.2004 kello 18:27, David Given kirjoitti:

 Rici Lake wrote:
In any event, the compiler should not need clues like this. It is easy enough to tell if the value of a local variable is not going to be used, regardless of its name. That is usually a programming error, of course: my Lua linter has a specific hook in it to avoid flagging unused local _'s in order to allow this idiom.

Sure, but the important is not to make life easier for the compiler, but to make life easier for the programmer. Why should I have to allocate a new variable, which means coming up with a name that doesn't conflict with any other names in my block, just to put a return parameter in that I'm not going to use? Far better to have syntax that says explicitly that I'm not going to use it. The _ idiom does *part* of this, but it can occasionally trip you up because it doesn't do what you expect it to do.

[insert interesting .sig here]