My two cents

bauss jj_1337 at live.dk
Fri Oct 20 00:26:19 UTC 2017


On Wednesday, 18 October 2017 at 08:56:21 UTC, Satoshi wrote:
> conditional dereferencing and stuff about that (same as in C#)
> foo?.bar;
> foo?[bar];
> return foo ?? null;

Tbh. these are some I really wish were in D, because it becomes 
tedious having to write something like this all the time:

return foo ? foo : null;

where

return foo ?? null; would be so much easier.

It especially becomes painful when you have something with 
multiple member accesses.

Like:

return foo ? foo.bar ? foo.bar.baz ? foo.bar.baz.something : null;

Which could just be:

return foo?.bar?.baz?.something;

>
> async/await (vibe.d is nice but useless in comparison to C# or 
> js async/await idiom)
> I want to create function returning Promise/Task and await 
> where I want to.
> e.g.
> auto result = device.start(foo, bar); // This is RPC to remote 
> server returning Task!Bar
> // do some important stuff
> return await result; // wait for RPC finish, then return it's 
> result

I don't think this is much necessary, because the fiber 
implementations already are able to let you write code close to 
this.

The only difference is you have to import the modules, but it's 
such a small thing I don't think you really need this.

>
> implement this thing from C# (just because it's cool)
> new Foo() {
>   property1 = 42,
>   property2 = "bar"
> };
>
>
>
> Thanks for your time.
> - Satoshi

I really wish this was implemented for classes too! Currently it 
exist for structs and it completely baffles me why it has never 
been implemented for structs.


More information about the Digitalmars-d mailing list