Implicit Constructors

Adam D. Ruppe destructionator at gmail.com
Fri Oct 13 14:50:44 UTC 2017


On Friday, 13 October 2017 at 14:43:41 UTC, jmh530 wrote:
> You should be able to that with Adam's jsvar module, no? The 
> issue is with

No, the D language doesn't allow it at all with structs; even 
with mine, you need to  `foo(var(0))` or similar (if you define 
the function, you could define as `foo(T...)(T t)` and wrap to 
vars internally). Of course, you could also do:

var foo = &.foo;
foo(0);

lol letting it convert all through the dynamic type :P


But actually, I really wish D just had implicit ctors on the 
types themselves. I think C++'s mistake was that implicit was the 
default, and you have to write `explicit`. If we did the 
opposite, where implicit was opt in, I think it would be useful 
without the worry C++ had.


More information about the Digitalmars-d mailing list