Add support implicit conversion between types

Peter Alexander peter.alexander.au at gmail.com
Sat Sep 7 08:09:28 PDT 2013


On Friday, 6 September 2013 at 13:15:21 UTC, Benjamin Thaut wrote:
> Am 06.09.2013 15:01, schrieb Dicebot:
>> Probably. But what is the gain? `foo(Foo(5))` looks better 
>> than `foo(5)`
>> to me in every possible way.
>>
>> For example, use case that justifies operator overloading 
>> (despite the
>> danger) in my eyes is ability to replace built-in types with 
>> custom
>> ones. What is the similar rationale for implicit conversion?
>
> Try implementing a custom string class in D that does not 
> depend on the GC and you will know. Your code will be littered 
> with explict constructions of strings, which makes it look 
> totally ugly.

Could you not just implement a .str property that does the 
conversion? Surely littering code with .str isn't too ugly?

I understand the desire for it, but implicit coercions truly are 
evil.


More information about the Digitalmars-d mailing list