What did you think about an implicitConversionOp ?

Mike slavo5150 at yahoo.com
Sun Dec 27 14:39:52 UTC 2020


On Saturday, 26 December 2020 at 15:48:49 UTC, sighoya wrote:

> What is your opinion regarding this?

There have been a number of proposals that have attempted to 
address the niche that implicit conversion operators fill, 
including...

1.  Implicit conversion operators
2.  Implicit constructors
3.  Multiple alias this

As I recall, the only one that has not been outright rejected is 
multiple alias this (https://wiki.dlang.org/DIP66).  In fact, it 
has been officially approved! But, the implementation 
(https://github.com/dlang/dmd/pull/8378) was never thoroughly 
reviewed let alone accepted, so it's unclear where things stand.

Walter's primary objection, as I understood it, was the 
complexity it introduced for classes and its interplay with the 
inheritance hierarchy.  Structs don't have an inheritance 
hierarchy, so I proposed a very simple solution:  Multiple alias 
this for structs only.  Classes already have what they need with 
D's kick-ass meta programming and multiple interface inheritance. 
  It's only structs that really need such a feature.  I wrote a 
slightly more detailed brain dump at 
https://forum.dlang.org/post/vggskphkqxtriqnavmnf@forum.dlang.org, so I refer the reader there.

Multiple alias this is already an approved DIP, so perhaps by 
reducing its scope to just structs, it may just need a champion 
willing to see an implementation through to completion.

With multiple alias this for structs, implicit conversion may not 
be needed.


More information about the Digitalmars-d mailing list