7 ms·
>it's not like commenting out variables is difficult. But if you comment var A that uses var B now B is unused and you need to commnet B, but now B was using
by simion314 4y ago
>it's not like commenting out variables is difficult.
But if you comment var A that uses var B now B is unused and you need to commnet B, but now B was using a function parameter C and this param is unused now so you need to update the function signature (I do not use Go,Zig so maybe they did not forced you to also use all the function params my experience is with linters where ehwn you comment something then more unused warnings appear)
- vanderZwan 4y agoWow sounds like you really need to clean up your codebase. Seriously, I have never had this problem while coding in Go, and I'm a very very sloppy coder.
- spoiler 4y agoWhat are you talking about? I don't understand how you've never encountered variables depending on each other. In any moderately complex function you'll have more than one expression, and those can depend on each other. And you want them to be named and assigned; it makes it easier to read and decode intent and debug things (unless you're one of those wizards who get it right on the first try every time, kudos to you then). I'd not approve a PR that inlines/embeds complex concepts within larger expressions just to avoid creating variables... Edit: typos
- vanderZwan 4y agoOf course I have encountered dependent variables, but if I have a long chain of unused variables that means that either that code is ready to go, or the code organization needs refactoring.
- hhmc 4y agoYou seem to be missing the whole point being made — they are unused because of (temporary) changes during prototyping.
- vanderZwan 4y agoAh yes, prototyping. The stage of coding where one has lots of snippets of code meant for trying things out quickly. Definitely a context full of long chains of dependent variables.
- hhmc 4y agoOne might imagine prototyping new functionality in a existing, complex, codebase..
- afiori 4y agoAt first you have a long chain of used variables that end up into a value used somewhere. If then you refactor away that single final value you need to delete all the previously used variables that now need to be "deallocated" by you.
- simion314 4y agoDude, it is about debugging, or work in progress... Did you ever tried to debug some issue and start commenting stuff to try and find the problematic area? Hell when I comment stuff soemtimes private function will get unused , so with a shit compiler you would need to also comment the private functions, remove unused classes etc. In my code I assure the linter will say 0 warnings.
- simion314 4y agoAs other said, it is not a good practice so inline all the code, I prefer well named variables, and I assume you can find examples in your code where you have a local variable that depends of a function parameter. Funny enough I was correcting my son c++ homework yesterday, he had a complex if statement like if (somefunction(m,n, y[j]) == m[j]) and I made him make a local variable to make it clear what is happening. then the code was easier to understand and debug because we culd print that local variable and see if is fine. Btw, try not too respond that smug, you proved that you are an inexperienced coder and a shit person.
- vanderZwan 4y agoI'm not so sure about that one, despite clearly being in the company of people who feel attacked, I'm not the one attacking people here. I'm commenting on code practices, and baffled at other people's rage about the compiler demanding that you don't have unused variables, but I haven't attacked anyone.
- simion314 4y agoYou commented about my code quality, but I will assume you were in a rush and missunderstood that I was talking about work in progress stuff and debugging, so if that was teh case I apologize (if is not the case then you might understand in a few years)
- xmonkee 4y agoI am seriously mind-blown that you've never encountered this problem in Go. You're trying something, and you see an error, you comment out a function and replace it with a print statement. And now suddenly you have to comment out a bunch of things up to the import statement just to fucking test out a simple hypothesis.
- nindalf 4y agoPossibly because the IDE helps with that. Including adding and removing import statements. I feel like this complaint is more theoretical than something felt by people using Go day to day.
- simion314 4y agoPeople on the internet contradicts you, You remind me of the Apple fanboys and the keyboard issue , people complain that they keyboard has problems and the fanboys respond with "is working with me, you are using it wrong, you are stupid and probably eat at your keyboard, you broke it yourself" https://www.google.com/search?q=go+lang++compiler+warnings+unused+variables+!g&sourceid=chrome&ie=UTF-8 https://www.google.com/search?q=go+lang++compiler+warnings+u... All those people reporting the issue are not Go developers? Or maybe are not true Go developers, just the other kind, the ones that want generic and nice things. But yeah, I am not a Go dev, I used linters and I would hate having to be forced to clear all the unused warnings before I can test the code.