June 04, 2022

On Friday, 3 June 2022 at 18:33:57 UTC, Jack wrote:

>

Rust does support it like that:

    const limit:i32 = 30;
    let n = 10;
    let mut r = if n > limit { "big" } else { "small "};
    println!("{} is {} than {}", n, r, limit);

do you think would be nice that in D as well? I find it can increase code reability...

I like the Python version of it with is reordered compared to Rust/D:

num_type = "even" if a % 2 = 0 else "odd"

June 04, 2022

On Saturday, 4 June 2022 at 22:05:36 UTC, JN wrote:

>

I like the Python version of it with is reordered compared to Rust/D:

num_type = "even" if a % 2 = 0 else "odd"

Yes, this is one is working well when the leftmost is the most common case and the right one is a fallback.

June 04, 2022
On 6/4/2022 9:15 AM, Nick Treleaven wrote:
> Just like `throw` is an expression in D now. It's type is noreturn, which implicitly converts to any type.

Which is causing unexpected problems :-/
June 05, 2022
On 05/06/2022 7:23 AM, Walter Bright wrote:
> On 6/4/2022 3:13 AM, rikki cattermole wrote:
>> How much work would it take to make it work for lets just say if, foreach and switch?
> 
> Using lambdas would be better.

Lol, I'll take that to mean its architecturally pretty far from where it needs to be.
June 05, 2022
On Sunday, 5 June 2022 at 00:48:04 UTC, Walter Bright wrote:
> On 6/4/2022 9:15 AM, Nick Treleaven wrote:
>> Just like `throw` is an expression in D now. It's type is noreturn, which implicitly converts to any type.
>
> Which is causing unexpected problems :-/

Isn't that more to do with nothrow expressions rather than throw as an expression? If we support nothrow functions then we get nothrow expressions. I could only find one throw expression bug, and that seems like it's a nothrow issue.
June 05, 2022
On Sunday, 5 June 2022 at 11:02:13 UTC, Nick Treleaven wrote:
> On Sunday, 5 June 2022 at 00:48:04 UTC, Walter Bright wrote:
>> On 6/4/2022 9:15 AM, Nick Treleaven wrote:
>>> Just like `throw` is an expression in D now. It's type is noreturn, which implicitly converts to any type.
>>
>> Which is causing unexpected problems :-/
>
> Isn't that more to do with nothrow expressions rather than throw as an expression? If we support nothrow functions then we get nothrow expressions. I could only find one throw expression bug, and that seems like it's a nothrow issue.

I meant noreturn expression, not nothrow!
June 05, 2022
On Sunday, 5 June 2022 at 00:48:04 UTC, Walter Bright wrote:
> On 6/4/2022 9:15 AM, Nick Treleaven wrote:
>> Just like `throw` is an expression in D now. It's type is noreturn, which implicitly converts to any type.
>
> Which is causing unexpected problems :-/

BTW: I would have expected try to become an expression such that one can write

   int v = try foo (...);
   catch (...) {...}
   ...

as in Perl

   my $v = eval { foo (...); };
   if ($@) ...
June 06, 2022

On Saturday, 4 June 2022 at 22:21:12 UTC, Ola Fosheim Grøstad wrote:

>

On Saturday, 4 June 2022 at 22:05:36 UTC, JN wrote:

>

I like the Python version of it with is reordered compared to Rust/D:

num_type = "even" if a % 2 = 0 else "odd"

Yes, this is one is working well when the leftmost is the most common case and the right one is a fallback.

It is so far ahead of the D era that it needs to be focused on...

For example (int i = 123_456_789;), the D feature that comes in ES12 has been there for years, but still no async/await in ES7! Anyway, will these features come one day?

>

&&=
||=
??=

Source: https://www.pullrequest.com/blog/javascript-es2021-you-need-to-see-these-es12-features/

June 06, 2022

On Monday, 6 June 2022 at 14:30:28 UTC, Salih Dincer wrote:

>

For example (int i = 123_456_789;), the D feature that comes in ES12 has been there for years, but still no async/await in ES7! Anyway, will these features come one day?

>

&&=
||=
??=

Things that makes code easier to read is always something any language designer should be willing to consider IMO. I guess null-specific operators could qualify.

Perhaps there is some generic way to do async/await, so developers could use it for custom Promises? Otherwise async/await is sort of out of place in @system, but fits well in @safe…

In general it would be nice if high level syntax is interacting through protocols so that one can use it for generic programming (like for-loops do).

June 06, 2022

On Monday, 6 June 2022 at 14:30:28 UTC, Salih Dincer wrote:

>

On Saturday, 4 June 2022 at 22:21:12 UTC, Ola Fosheim Grøstad wrote:

>

On Saturday, 4 June 2022 at 22:05:36 UTC, JN wrote:

>

I like the Python version of it with is reordered compared to Rust/D:

num_type = "even" if a % 2 = 0 else "odd"

Yes, this is one is working well when the leftmost is the most common case and the right one is a fallback.

It is so far ahead of the D era that it needs to be focused on...

For example (int i = 123_456_789;), the D feature that comes in ES12 has been there for years, but still no async/await in ES7! Anyway, will these features come one day?

>

&&=
||=
??=
that's really a nice set of operators to have...
Source: https://www.pullrequest.com/blog/javascript-es2021-you-need-to-see-these-es12-features/