I would make the case that the dialect issue you describe is already present, since developers can already choose to work in Double
and convert to CGFloat
only when passing the value into API that requires it, or work entirely in CGFloat
, possibly converting Double
values from APIs that return them. Or, they can choose a third dialect, where a developer tries to minimize the number of conversions, so as to have the least cluttered code, in which case they might switch between the two styles in the same code base depending on the calculations involved.
I believe since this proposal makes it easiest to use Swift's default floating point type Double
that the proposed change will likely make doing intermediate calculations in Double
much more common.
Of course, developers could choose to work in one type or the other just as they can today, but improving the ergonomics of working with Double
is likely to consolidate coding style around Double
, especially since it matches the typical style for working with floating point types elsewhere in Swift.
I would say that having Double
be the default type used in Swift to interpret floating point literals does declare a strong preference that Double
is the preferred floating point type, as well as that being stated in the documentation.
On platforms with a 32-bit CGFloat
, frameworks that rely on CGFloat
almost always also use the types CGPoint
, CGSize
, and CGRect
. These types allow developers to initialize using Double
values, and then silently narrow them to 32-bit CGFloat
members. Those initializers have been in place for at least five years, without causing widespread issues. So, in practice there does not seem to be a practical safety issue with silent conversion to 32-bit CGFloat
.
There is even less reason to worry. Since iOS and macOS are now exclusively 64-bit platforms, CGFloat
and Double
have identical 64-bit representations, so there is no loss moving between them.