Suggestion: def _unused_function do

I was writing code that included a function I would call later (so it wasn’t called yet). I got a warning, and I thought I could put an underscore before the function name, the way it works for variables, but that didn’t work. While writing @compile :nowarn_unused_functions isn’t a terrible hardship, it would be nice to simply write:

def _unused_function do
end

I’m not sure I see the use in this. Not using a variable have legitimate reasons to exist in elixir programs. E.g. a certain parameter might only be used some parts of the branched execution of multiple function heads.

An unused private function has no such reason to exist.

Also it’s just a warning, which can easily be ignored until a chunk of code is completed. E.g. zig actually refuses to compile if you have e.g. unused variables.

2 Likes

Yes, while I’m not familiar with Zig I agree that (besides unused parameters) for variables there is other value such as documentation/readability. The only use case that comes to mind is the one I was running into: telling the compiler “I know this is unused” while writing unfinished code (and I expected it to work consistently). I often have an urge to fix warnings immediately, so it’s distracting.

Me too, but I just comment them out. Best solved with your editor, I’d say! Depending on your editor, you could look for something that gives you “comment out function” with a simple key combo.

1 Like