February 06, 2022
On Sunday, 6 February 2022 at 13:40:00 UTC, Paolo Invernizzi wrote:
> On Sunday, 6 February 2022 at 13:33:53 UTC, Paul Backus wrote:
>>
>> @mustUse is a user-defined attribute, and the official style guide says that names of UDAs should be camelCased:
>>
>> https://dlang.org/dstyle.html#naming_udas
>
> ... This matches conventions of the built in attributes like @safe,  __@nogc__  ...

Presumably this is referring to the part about the first letter being lower-case, since the built-in attributes are quite obviously not camelCased.
February 06, 2022
On Sunday, 6 February 2022 at 14:00:15 UTC, Paul Backus wrote:
> On Sunday, 6 February 2022 at 13:40:00 UTC, Paolo Invernizzi wrote:
>> On Sunday, 6 February 2022 at 13:33:53 UTC, Paul Backus wrote:
>>>
>>> @mustUse is a user-defined attribute, and the official style guide says that names of UDAs should be camelCased:
>>>
>>> https://dlang.org/dstyle.html#naming_udas
>>
>> ... This matches conventions of the built in attributes like @safe,  __@nogc__  ...
>
> Presumably this is referring to the part about the first letter being lower-case, since the built-in attributes are quite obviously not camelCased.

While I like a lot and welcome the addition of this attribute (so thank you!), I humbly  ask to reconsider using   the full lowercase alternative instead of camel case.

Let's conform with the other built-in attributes listed into the specs of the language, avoiding what would be another special case to remember.


February 06, 2022

On Sunday, 6 February 2022 at 13:33:53 UTC, Paul Backus wrote:

>

On Sunday, 6 February 2022 at 10:55:20 UTC, Daniel N wrote:

>

Guess I'm way too late, I just find it very strange you settled on mixedCase, it's not used for anything else. (nothrow @nogc). I also don't agree with the motivation that @use is hard to search for because @ is an unusual symbol.

@mustUse is a user-defined attribute, and the official style guide says that names of UDAs should be camelCased:

It is kinda confusing to call it a user-defined attribute if it is recognized by the compiler.

I dislike the camel case as well, and the name is less clear than "nodiscard" in my opinion.

February 06, 2022
On Sunday, 6 February 2022 at 14:32:31 UTC, Paolo Invernizzi wrote:
> While I like a lot and welcome the addition of this attribute (so thank you!), I humbly  ask to reconsider using   the full lowercase alternative instead of camel case.
>
> Let's conform with the other built-in attributes listed into the specs of the language, avoiding what would be another special case to remember.

There is precedent for compiler-recognized UDAs using camelCase in core.attribute.gnuAbiTag [1], as well as the various LDC-specific attributes [2]. So no matter what I choose here, it will be inconsistent with something.

If you strongly prefer the lower-case version, you can always rename it in your own code:

    import core.attribute: mustuse = mustUse;

    @mustuse struct MyStruct
    {
        // ...
    }

[1]: https://druntime.dpldocs.info/core.attribute.gnuAbiTag.html
[2]: https://wiki.dlang.org/LDC-specific_language_changes#Attributes
February 06, 2022
On Sunday, 6 February 2022 at 14:56:42 UTC, Paul Backus wrote:
> On Sunday, 6 February 2022 at 14:32:31 UTC, Paolo Invernizzi wrote:
>> While I like a lot and welcome the addition of this attribute (so thank you!), I humbly  ask to reconsider using   the full lowercase alternative instead of camel case.
>>
>> Let's conform with the other built-in attributes listed into the specs of the language, avoiding what would be another special case to remember.
>
> There is precedent for compiler-recognized UDAs using camelCase in core.attribute.gnuAbiTag [1], as well as the various LDC-specific attributes [2]. So no matter what I choose here, it will be inconsistent with something.
>
> If you strongly prefer the lower-case version, you can always rename it in your own code:
>
>     import core.attribute: mustuse = mustUse;
>
>     @mustuse struct MyStruct
>     {
>         // ...
>     }
>
> [1]: https://druntime.dpldocs.info/core.attribute.gnuAbiTag.html
> [2]: https://wiki.dlang.org/LDC-specific_language_changes#Attributes

That's fine, I will not insist more, hoping not to see in the future it extended as a function attribute ... you know ...

int foo() @nogc @safe @mustUse etc etc ...


February 06, 2022

On Sunday, 6 February 2022 at 13:33:53 UTC, Paul Backus wrote:

>

On Sunday, 6 February 2022 at 10:55:20 UTC, Daniel N wrote:

>

Guess I'm way too late, I just find it very strange you settled on mixedCase, it's not used for anything else. (nothrow @nogc). I also don't agree with the motivation that @use is hard to search for because @ is an unusual symbol.

@mustUse is a user-defined attribute, and the official style guide says that names of UDAs should be camelCased:

https://dlang.org/dstyle.html#naming_udas

"Hard to search for" in this context means "hard to Google for", not "hard to grep for". Search engines tend to ignore symbols like @.

If you just google for "dlang attributes" you should be able to find what you search for, regardless of what it is called, thus personally I think greppability is the only thing we have to cater for.

If the attribute is in core or truly built-in feels like an implementation detail, if nogc was created today, it also probably would have been listed in core.attribute. By using a different naming convention we actually block refactoring/cleanup of the frontend by moving build-in attributes to the core.attribute.

However by choosing "use" we could avoid the entire discussion about which case to use...

Best Regards,
Daniel N

February 06, 2022

On Sunday, 6 February 2022 at 14:44:40 UTC, Ola Fosheim Grøstad wrote:

>

On Sunday, 6 February 2022 at 13:33:53 UTC, Paul Backus wrote:

>

@mustUse is a user-defined attribute, and the official style guide says that names of UDAs should be camelCased:

It is kinda confusing to call it a user-defined attribute if it is recognized by the compiler.

Compiler-recognized UDAs are an established feature of D. See core.attribute for more examples.

>

I dislike the camel case as well, and the name is less clear than "nodiscard" in my opinion.

I suppose you'll have to take that up with Walter, since he's the one who vetoed "nodiscard".

To be honest, though, I can see where he's coming from. When writing DIP 1038, I made a conscious effort to avoid using the term "non-@nodiscard", due to the double negative. With a positively-phrased name like @mustUse, that problem disappears.

February 06, 2022
On Sunday, 6 February 2022 at 15:17:35 UTC, Paul Backus wrote:
> On Sunday, 6 February 2022 at 14:44:40 UTC, Ola Fosheim Grøstad wrote:
>> On Sunday, 6 February 2022 at 13:33:53 UTC, Paul Backus wrote:
>>>
>>> @mustUse is a user-defined attribute, and the official style guide says that names of UDAs should be camelCased:
>>
>> It is kinda confusing to call it a user-defined attribute if it is recognized by the compiler.
>
> Compiler-recognized UDAs are an established feature of D. See [`core.attribute`][1] for more examples.
>
>> I dislike the camel case as well, and the name is less clear than "nodiscard" in my opinion.
>
> I suppose you'll have to take that up with Walter, since he's the one who vetoed "nodiscard".
>
> To be honest, though, I can see where he's coming from. When writing DIP 1038, I made a conscious effort to avoid using the term "non-`@nodiscard`", due to the double negative. With a positively-phrased name like `@mustUse`, that problem disappears.
>
> [1]: https://druntime.dpldocs.info/core.attribute.html

@hold (or @held) ? donwannaopenacanofworms ... my last post really :-P

(btw, It's a great companion for sumtype! thank you again!)




February 06, 2022
On Sunday, 6 February 2022 at 15:24:17 UTC, Paolo Invernizzi wrote:
> @hold (or @held) ? donwannaopenacanofworms ... my last post really :-P

Pretend that you are a beginning D programmer, and you come across one of the following declarations while reading someone else's code:

    @use struct Result
    {
        // ...
    }

    @hold struct Result
    {
        // ..
    }

    @mustUse struct Result
    {
        // ...
    }

You have never seen any of these attributes before in your life, and there are no comments explaining what they mean--all you have to go on is the name. Which name is are you most likely to guess the correct meaning for: "use", "hold", or "mustUse"?
February 06, 2022

On Sunday, 6 February 2022 at 14:56:42 UTC, Paul Backus wrote:

>

If you strongly prefer the lower-case version, you can always rename it in your own code:

import core.attribute: mustuse = mustUse;

This response is getting a bit longwinded, and I really want this feature, but…

  1. Process: I apologise for having missed the original DIP feedback thread. I understand that this retrospective feedback might be annoying and is easy to dismiss, but please consider making this feature as attractive as possible and let us focus on improving the language proper rather than shifting everything to the standard library where the threshold is lower?

  2. Renaming key features: The renaming looks reasonable to me at the first glance, but when I think about it some more I think this will lead to a mess and make code less readable if many developers start doing this. I don't think programmers should be allowed to rename it at all! Maybe there should be a popularity vote for the syntax?

  3. The politics of language improvements: I don't think this should be a library type. I think this feature is too important for that. To me this smells of let's move the syntax to a library to avoid any discussion about breaking changes. Design considerations should not become political, we need to get rid of politics and focus on principled strategies that makes the whole eco system attractive to more developers (the ones we don't have).

  4. Mandatory eco system: How does the compiler recognize it? I hope it is by intrinsics and not by "symbol-path". That seems to be an import omission in the DIP, unless I overlooked it. For instance, if some sub-group of D programmers want grow their own independent niche-runtime-libary-combo, are they then free to write their own standalone hierarchy? Or is the standard library now taking over the introduction of language features in order to downplay politics?

  5. Make syntax pretty: It would actually be better to just have this as part of the formal syntax with a non-attribute without the "@". One thing that makes D source code hard on the eyes is the "@" noise. The current parser is a bit primitive, but you can often accept terms in the syntax without making them keywords with a little bit of careful planning.

  6. Strategic positioning: And yes, C++ syntax is becoming ugly too, but this is also why making D pretty should be a strategic concern! Can we afford to add more visual noise? I think not…