3 ms·
> "I'm quite surprised objective-c doesn't warn by default if you try to a potentially lossy conversion without an explicit cast." Implicit casts that are prec
by potatolicious 11y ago
> "I'm quite surprised objective-c doesn't warn by default if you try to a potentially lossy conversion without an explicit cast."
Implicit casts that are precision-lossy (say, int32 to int16) are definitely warnings in Obj-C, the issue is that most(?) Obj-C devs sail right past said warnings, and most projects are not configured to flag these as errors instead.
One of the other issues with implicit casts is that it's often non-obvious if what you're doing is lossy - there are a lot of aliased or conditional types (for example: a CGFloat is a float on 32-bit systems, and double on 64-bit)
Also things like time measurement - a NSTimeInterval is a double, so casting it down to a float is lossy, but not obviously so because for the most part we don't think about what's the actual object backing a lot of system types.