What is the reasoning behind the lack of conversions when passing parameters

Carl Sturtivant sturtivant at gmail.com
Wed Feb 14 00:38:17 UTC 2024


On Sunday, 11 February 2024 at 19:26:39 UTC, Walter Bright wrote:
> We've considered it many times, and have decided against it due 
> to the consistently negative experience with it in C++. Despite 
> it being opt-in, it gets routinely abused.
>
> Overloading, even with all its restrictions in D, still gets 
> abused to create incomprehensible code. When debugging Phobos 
> code, often the only way I can figure out which overload is 
> used is to insert `pragma(msg)` statements.
>
> Sumtypes and pattern matching are important issues, and I'll 
> talk about that at the upcoming DConf online.

Variant is important to some of us because of its universality. 
If all conversions are blocked for parameter passing, can a 
replacement of Variant (say Any) be added to the list to be a 
part of the language?

This would be so that any literal or value of any type can be 
passed to a parameter of type Any, enabling naive scripting and 
experimenting in any context without an import.


More information about the Digitalmars-d mailing list