3 ms·
> Almost every time I've ever tried to silence the type checker (in any other language) it resulted in a bug. What does it even mean? You can't silence a type
by Thaxll 5y ago
> Almost every time I've ever tried to silence the type checker (in any other language) it resulted in a bug.
What does it even mean? You can't silence a type checker.
- tasn 5y agoExactly what the sibling comment said, you can do it in many languages. Also, the comment I replied to suggested just that ("cast to any"), which is the context. :)
- HideousKojima 5y agoYou can in JS/TS and Python. Technically you could even do it in a language with a fairly strong type system like C# or Java by casting to object or dynamic, though the code using the cast object after that will probably be very unidiomatic.
- Thaxll 5y agoCan't you cast to any in Rust as well?
- fzzzy 5y agoNo. Rust does not have the equivalent of Object or void *.
- vladvasiliu 5y agoThere's the Any trait [0]. Not sure if this is exactly like void* in C, but this doesn't look particularly ergonomic to use. [0] https://doc.rust-lang.org/std/any/index.html https://doc.rust-lang.org/std/any/index.html
- sondr3 5y agoTo expand on the others, unlike in TS/JS, Python etc you can cast to the `Any`-trait but cannot use it as if it is any value, you need to convert it to the type you want and then handle the errors. A function that accepts `&str` will never accept a `Any` value, unlike in TS where you can override the type checker using `as`. Worth noting that TypeScript's type system is unsound [0] too. [0]: https://www.typescriptlang.org/docs/handbook/type-compatibility.html https://www.typescriptlang.org/docs/handbook/type-compatibil...