https://github.com/search?q=ugly+hack&ref=cmdform&type=Code
https://github.com/search?utf8=%E2%9C%93&q=filename%3Aid_rsa...
https://github.com/search?p=3&q=extension%3Aphp+mysql_query+...
131–140 of 214 posts
https://github.com/search?q=ugly+hack&ref=cmdform&type=Code
https://github.com/search?utf8=%E2%9C%93&q=filename%3Aid_rsa...
https://github.com/search?p=3&q=extension%3Aphp+mysql_query+...
"This should never happen" is a design pattern of defensive programming. This is the same pattern for assert. The usual use is to catch errors caused by misuse of a method. There is some invariant that the method assumes but is not enforced by the type signature of the interface. So if something goes wrong in outside code, or someone tries to use the method incorrectly, the invariant is not satisfied. When you catch…
It's a sub-pattern of "ain't got time for dat". Developer knows that condition should never happen, but is not inclined to prove it (as represented by coding type checking or other handling) yet realizes it shouldn't be ignored outright (if only to document the unproven condition in code, or to shut the compiler up about incompleteness warnings).
You could be inclined to see it as "is not inclined to prove it", but I prefer to think it happens mostly because someone didn't think they changed something that could affect that (i.e. "I was sure that simple change to the boolean expression was equivalent when I made it...")
Earlier quoted context omitted.
Sometimes you do it because the compiler insists a case (that really can never happen) needs to be handled. It happens a lot to me in Rust and Go.
Rust has support for "this can not happen" in core: http://doc.rust-lang.org/core/macro.unreachable!.html GCC also has an extension for that: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index... which Clang supports: http://clang.llvm.org/docs/LanguageExtensions.html#builtin-u...
https://raw.githubusercontent.com/bjacob/builtin-unreachable...
Earlier quoted context omitted.
And this pattern is exactly why I prefer compile time type safety in my languages. This pattern is still sometimes necessary but there is a whole class of error this pattern gets used for that you can many times eliminate.
What's interesting is that (as described in the present top comment on this article, about "CALL BRIAN"), if the abstraction of "type safety" is leaky (as it is , e.g. in the presence of memory or hardware errors), this kind of paranoia can actually have real-world benefits even though you can prove the impossibility of the code running using static analysis. Sometimes the important artifact is the executable in the…
You say it "is" leaky in the presence of memory corruption. However that is not necessarily true. One could model software memory verification within a type system. Meaning, you could guarantee at compile time that each time a variable is read it is verified via checksum against its last written value. This would not be particularly efficient, but the point stands that type systems can be used (and should be used) to model hardware failures.
This is no different than network link failures, etc...
1: https://github.com/search?utf8=%E2%9C%93&q=should+not+get+he...
Earlier quoted context omitted.
It's a sub-pattern of "ain't got time for dat". Developer knows that condition should never happen, but is not inclined to prove it (as represented by coding type checking or other handling) yet realizes it shouldn't be ignored outright (if only to document the unproven condition in code, or to shut the compiler up about incompleteness warnings).
> is not inclined to prove it (as represented by coding type checking or other handling) This is known as a reachability problem that in the general case cannot be proven . So, "not inclined" may actually mean "can't (in any reasonable amount of time)".
Using github to search like this reminds me of how a CS professor of mine would show the "best commit messages of the year" (homework was submitted via git) by looking for various patterns like all caps, all symbols, etc. http://www.slideshare.net/bsotomay/uchicago-cmsc-23300-the-b...
Spouses less likely to run away into the dark abyss.
Bald inmate digging grows hair.
Player can die from lava while praying successfully.
Colonists will no longer stare each other to death.
Trash monsters will now have a chance to drop the intended cat ear colors.
Suicide animation speeds up search for apples, berries.
Fix trees not going to their burnt state when they go to sleep while on fire.
Potions are tasting much better now, especially the harmful ones.
https://twitter.com/TheStrangeLog/