Yes, this is the important discussion to be had, and this discussion is exactly what I'm encouraging. Your post makes two different arguments 1) implicit conversions are critical for some things, but 2) you don't like implicit conversions. Your conclusion is that they should be hard coded into the compiler as a defense mechanism.
We (folks working on Swift a long time + evolution) have gone around this "policy vs mechanism" wheel several times in the past, e.g. when SE-0195 Dynamic Member Lookup was added, early in the language design when we had (what became) the ExpressibleBy...
protocols adoptable by user-defined types, user-inventable operators, emoji identifiers, more recently in the discussion about SE-0302 Sendable where we discussed locking down Sendable conformance to prevent bugs etc. Frequently there is a "fear of abuse" vs "generality" question that comes up - go read the DynamicMemberLookup reviews to see all the concerns of "everyone will start conforming to this and then no one will know what any code does" concerns.
Reasonable people have different opinions, but I have /consistently/ (across the last 11 years, across many language features from the very beginning) been of the opinion that:
- "Swift benefits from strong API design guidelines"
- We need composable language features with strong designs.
- "The API Author Knows Best".
The reason for the first is that you want consistency across the ecosystem (which isn't something that can be mechanically enforced in general). The second is hopefully obvious. The third is because domain-specific APIs have different constraints and the authors of those APIs are the best positioned to understand the needs of their customers. With #1 and #2, those API authors (who are professional software engineers, not children that need to be coddled) can weigh the tradeoffs and make informed decisions.
To make this concrete, come back to the majority of your post outlining how important it is to do bindings to C, and how this is all special. It turns out that C isn't the only language that Swift binds to - PythonKit is also a pretty important thing for a class of users, and it would also benefit from specific adoption of narrow implicit conversions.
I would much rather have a unifying theory and flush all those special cases out of the compiler. Are we going to start adding special case conversions into the compiler for other language bindings?
-Chris
EDIT: Also, your post and those of others make a specific assumption that what we end up with would be C++-like or __conversion
like. I'm not sure why it always comes back to this, of course we wouldn't carry forward known mistakes into the future.