August 02

On Thursday, 1 August 2024 at 14:20:29 UTC, user1234 wrote:

>

That was a general criticism of implicit construction.

We are only talking about it in the context of returning from a function.

>

The classic example is

struct S {int i;}
function f(S s);
function f(int i);

unittest { f(0); } // both match

unless the idea would rather be to allow implicit construction only in the context of initialization.

You are wasting my time. Show me how this applies to retuning from within a function.

August 02

On Thursday, 1 August 2024 at 07:25:53 UTC, Emma wrote:

>
Option!int something() {
  return None(); // Error: cannot implicitly convert expression `None()` of type `None` to `Option!int`
}

Not D per se, but you can check Adam D. Ruppe's current work.
If I am not mistaken, the thing you are asking for is already possible in the nightly release.

https://dpldocs.info/this-week-in-arsd/Blog.Posted_2024_02_20.html#implicit-construction

Juraj

1 2
Next ›   Last »