February 09, 2022

On Wednesday, 9 February 2022 at 17:48:29 UTC, Guillaume Piolat wrote:

>

There is also the Nim "discard" statement.

Just change the default to not allowing return values to be discarded. When you really want to, do:

cast(void) function_with_return_value(…)

Or something like that.

February 09, 2022
On Wednesday, 9 February 2022 at 17:40:31 UTC, jmh530 wrote:
> On Wednesday, 9 February 2022 at 16:21:24 UTC, Paul Backus wrote:
>> [snip]
>>
>> In D, there is no existing word for this, so from that perspective both "mustuse" and "nodiscard" are equally valid.
>>
>> In other languages, there are multiple existing words:
>>
>> - C++17: [[nodiscard]]
>> - C (gcc/clang): __attribute__((warn_unused_result))
>> - Rust: #[must_use]
>>
>> If you are used to C++, then you will find "nodiscard" natural, and "mustuse" will require you to learn a new word. If you are used to Rust, then you will find "mustuse" natural, and "nodiscard" would have required you to learn a new word.
>>
>
> But what color should the bike shed be? ;)

Color is a perceptual experience, and its impact on psychological functioning has been well researched.
February 09, 2022
On Wednesday, 9 February 2022 at 17:54:17 UTC, rikki cattermole wrote:
>
> On 10/02/2022 5:21 AM, Paul Backus wrote:
>> - C (gcc/clang): __attribute__((warn_unused_result))
>
> C23 will also have [[nodiscard]]
>
> Not only will it have that on functions, but also support a string too.
>
> Unfortunately its looking like we have chosen to diverge from C, and therefore won't be completely C compatible soon.
>
> Will be exciting as to what kind of bugs crop up because of this!

Exactly. So now C++ and C will have nodiscard, and when those developers come over to D (the developers most targetted by D btw), someone will have to explain why D decided on a different color for the bikeshed.

1 2 3 4 5 6 7
Next ›   Last »