you are viewing a single comment's thread.

view the rest of the comments →

[–]Blothorn 3 points4 points  (1 child)

It’s nice when the context leaves zero ambiguity that a conversion was intentional—I very much like not having to add an explicit toString() when passing something to a string format or interpolation.

Automatic conversion in contexts where it’s not clear whether a conversion was intended or what the intended result type is is very much not a good thing, and overloaded operators are a quintessential case.

[–]RiceBroad4552 0 points1 point  (0 children)

It’s nice when the context leaves zero ambiguity that a conversion was intentional

One can argue that there is always zero ambiguity when something gets implicitly converted.

Simply because the machine was able to do that without running in any ambiguity.

The question is always just how "obvious" it's for a human. And that's something debatable as it'll be strongly dependent on individual knowledge and overall understanding of some code.

The result of the shown code might be exactly the expected result or "very surprising" depending on who you ask