It works and is a pile of jank - Python
It doesn’t work and is a pile of jank - C++
You violated gods laws with how bad your code is and it still runs (right through the wall) - C
You wouldn’t typecast a car.
For our American friends: the Opel Corsa is a car.
In bigger projects, you tend to miss type safety really bad, really fast. Rust has it built in, Python can have it bolted on. That’s simply one of the many aspects to consider when choosing your programming language.
But don’t worry about it too much. If one thing’s for sure, it’s that you will regret that choice in any case.
C when I cast a
char * *
to achar * * const
: okC when I cast a
char * *
to achar * const *
: okC when I cast a
char * *
to achar const * *
: WTFC when I cast a
char * *
to achar const * const *
: okThe WTF case isn’t allowed because it would allow modification of the const. From https://en.cppreference.com/w/cpp/language/implicit_conversion
int main() { const char c = ‘c’; char* pc; char** ppc = &pc; const char** pcc = ppc; // Error: not the same as cv-unqualified char**, no implicit conversion. *pcc = &c; *pc = ‘C’; // If the erroneous assignment above is allowed, the const object “c” may be modified. }
Perl when I iterate over an object and treat the result as a hash reference: “fine, whatever. Fuck you, tho”
You know, I always wondered what the original image looked like, and even trusty Know Your Meme doesn’t show it. It looked like this:
a compile-time error is highly preferable to a run-time error