Closed vi closed 3 years ago
Thanks - I just figured that out. (It took me a lot of searching to realise that was an option - it would be great if the compiler error suggested that as a fix).
the first is done automatically by ZLS' autosave feature
.. But, this is the worst of all worlds as far as this error goes. It means that I don't even get a compiler warning when I have unused variables. My code is silently "corrected" regardless of whether or not the fix matches my intent. If you're going to autofix code to suppress this error, zig may as well just turn the error off entirely.
My code is silently "corrected" regardless of whether or not the fix matches my intent. If you're going to autofix code to suppress this error, zig may as well just turn the error off entirely.
@josephg Just to clarify, this is the reason why the Zig (core) toolchain has so-far taken a stance against automatic edits.
The mentioned "autofix" mechanism is an opt-in feature (configuration setting enable_autofix
) of ZLS (which is community-maintained).
(I would assume the intent was that people would either immediately spot the autofixes, or re-read code after writing it to look for unintended uses of _
- I don't use it myself, so can't comment on efficiency one way or the other.)
or re-read code after writing it to look for unintended uses of
_
This is significantly worse than a compiler warning, but I can see how it ended up this way if zls is community maintained and has a different opinion about this issue than the zig compiler authors. Sorry for temporarily hijacking the thread - and thanks for the advice. I'll give that a whirl.
As far as I understand, Zig places great emphasis on code maintainability.
Unfortunately, restrictions required for it are at conflict with ease of development, debugging and prototyping.
I suggest to have a special Zig mode that trades code maintainability for short-term ease, ergonimics and speed of hacking. Command-line option may be
--sloppy
or--devmode
or--lax
.Proposed rules for such mode:
--sloppy
as a minimal acceptance test.--sloppy
mode code.switch
cases and so on.--sloppy
mode, as an eye sore reminding that it is not supposed to be permanently enabled.--sloppy
without modifying source code should not affect program behaviour.@compileError
if it is not enabled. The reverse should not be idiomatic.--sloppy
mode. Master builds may be required.