News for hackers. Stuff that matters.
Re:Safe dead code removal in a pure functional language by kazinator on Thursday January 28, 2021 @10:02PM (#25953230)
There is no safe dead code removal. If the code being removed has any effects in it (the encoding of which is possible in a pure language), the fact that it's unreachable could be a bug. If you sneakily just remove it without telling the user, you're colluding with the bug.

Recently, I discovered an like-new pair of shoes at the bottom of a closet. I bought them some four or five years ago, I guess, and somehow forgot about them. They got buried under other items. This was a day or two before Christmas; it was like an unexpected present.

Now, someone could have surreptitiously entered my home at any time before that and removed these "dead shoes". I would never have known.

So therefore, it wouldn't be stealing, right? It's a "semantics-preserving transformation of someone's belongings".

Re:Safe dead code removal in a pure functional language by jfmengels1 on Friday January 29, 2021 @02:24AM (#25954945)
And that is exactly the reason why the tool from the article asks you for confirmation at every step. So that you can actually go and say "oh, no, I want to keep and use that".

But even if you do blindly accept each fix, the behavior of the program won't change.

Re:Safe dead code removal in a pure functional language by setr on Thursday January 28, 2021 @10:17PM (#25953361)
Well, it’s safe in that it’s correct. You could remove it without warning, and the program would behave the same.

That does not preclude notifying the user, or getting confirmation