
14 Sep
2008
14 Sep
'08
7:07 a.m.
2008/9/14 John Goerzen
2) Variable x defined but not used
I most often ignore this when it occurs in a function definition. Sometimes I may have a function that could be written
foo _ (x, _) _ = bar (x + 5)
But for clarity's sake on what all the unused args are, which really helps for future maintainability, I'll usually use a descriptive -- but unused -- variable name.
This doesn't appear to be commonly known, but actually any identifier that /starts/ with an _ will not trigger the unused-arg warning. So if you wrote your example like this: foo _stuff (x, _y) _more = bar (x + 5) It would satisfy both the compiler and your desire for descriptive variable names. Cheers, Max