Containers

Paul Backus snarwin at gmail.com
Wed Sep 1 02:19:22 UTC 2021


On Wednesday, 1 September 2021 at 01:38:49 UTC, jmh530 wrote:
>
> My recollection is that opHeadMutable [1] was intended as a way 
> to inform the compiler that the conversion is valid.
>
> [1] 
> https://forum.dlang.org/post/cpxfgdmklgusodqouqdr@forum.dlang.org

It looks like `opHeadMutable` is basically a restricted form of 
"implicit `opCast`"--that is, rather than allowing the programmer 
to define *arbitrary* implicit conversions, it lets them define 
implicit conversions of the form `qual(Template!(Args))` -> 
`Template!(qual(Args))`.

IMO it is a compromise that both sides would find unsatisfying. 
Those who want convenient implicit conversions will not be happy 
with it because there are important cases it does not cover (e.g. 
`qual(Template!(qual(T)))` -> `qual(Template!T)`), but it is 
still flexible enough that anyone opposed to user-defined 
implicit conversions in general will likely find it hard to 
stomach.


More information about the Digitalmars-d mailing list