Re: Added copy constructors to "Programming in D"

2022-02-09 Thread Ali Çehreli via Digitalmars-d-announce
On 2/9/22 18:11, Meta wrote: > Why do we even bother with `in` when we can do: > > alias In(T) = const scope T; > > void test(In!int n) { > pragma(msg, typeof(n)); > } > > ? > > onlineapp.d(3): Deprecation: storage class `scope` has no effect in type > aliases > const(int) > > ...oh I

Re: Added copy constructors to "Programming in D"

2022-02-09 Thread Meta via Digitalmars-d-announce
Why do we even bother with `in` when we can do: alias In(T) = const scope T; void test(In!int n) { pragma(msg, typeof(n)); } ? onlineapp.d(3): Deprecation: storage class `scope` has no effect in type aliases const(int) ...oh

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread forkit via Digitalmars-d-announce
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

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread forkit via Digitalmars-d-announce
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

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-announce
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.

Re: Added copy constructors to "Programming in D"

2022-02-09 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, Feb 09, 2022 at 10:28:15AM -0800, Ali Çehreli via Digitalmars-d-announce wrote: [...] > - const is a promise > > - immutable is a requirement [...] Strictly speaking, that's not really an accurate description. :-P A more accurate description would be: - const: I cannot modify the data

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread apz28 via Digitalmars-d-announce
On Wednesday, 9 February 2022 at 16:21:24 UTC, Paul Backus wrote: On Wednesday, 9 February 2022 at 14:30:30 UTC, Guillaume Piolat wrote: On Monday, 7 February 2022 at 19:57:28 UTC, forkit wrote: First, I'm not 'insisting' on anything. I'm just expressing a view. nodiscard is already used by

Re: Added copy constructors to "Programming in D"

2022-02-09 Thread Ali Çehreli via Digitalmars-d-announce
On 2/9/22 02:15, Anonymouse wrote: On Saturday, 8 January 2022 at 02:07:10 UTC, Ali Çehreli wrote: 2) The other noteworthy change in the book is my now-different stance on variables: Now I recommend 'const' over 'immutable' for variables. I'm curious, could you elaborate a bit on this? I

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread rikki cattermole via Digitalmars-d-announce
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

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Guillaume Piolat via Digitalmars-d-announce
On Wednesday, 9 February 2022 at 16:21:24 UTC, Paul Backus wrote: C++ is quite popular, but it is not the only popular language, and there are many D programmers who have never used C++ at all, let alone C++17 or later. Therefore, it is a mistake to assume that all or even most D programmers

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread jmh530 via Digitalmars-d-announce
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):

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Paul Backus via Digitalmars-d-announce
On Wednesday, 9 February 2022 at 14:30:30 UTC, Guillaume Piolat wrote: On Monday, 7 February 2022 at 19:57:28 UTC, forkit wrote: First, I'm not 'insisting' on anything. I'm just expressing a view. nodiscard is already used by more programmers that D is likely to ever adopt. Indeed, it's

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Guillaume Piolat via Digitalmars-d-announce
On Wednesday, 9 February 2022 at 14:30:30 UTC, Guillaume Piolat wrote: Hence some does of of reusing, some dose of reuse*

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Guillaume Piolat via Digitalmars-d-announce
On Monday, 7 February 2022 at 19:57:28 UTC, forkit wrote: First, I'm not 'insisting' on anything. I'm just expressing a view. nodiscard is already used by more programmers that D is likely to ever adopt. Indeed, it's these programmers that D is trying to adopt. I'm not sure forcing such

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-announce
On Wednesday, 9 February 2022 at 10:59:03 UTC, Dukc wrote: You're implying that your opinion is rational and apolitical, disagreeing with it is irrational politics. I am implying that there are many symptoms of people not being willing to champion the best possible design and instead have

Re: DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

2022-02-09 Thread Dukc via Digitalmars-d-announce
On Sunday, 6 February 2022 at 15:43:39 UTC, Ola Fosheim Grøstad wrote: 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

Re: Added copy constructors to "Programming in D"

2022-02-09 Thread Anonymouse via Digitalmars-d-announce
On Saturday, 8 January 2022 at 02:07:10 UTC, Ali Çehreli wrote: 2) The other noteworthy change in the book is my now-different stance on variables: Now I recommend 'const' over 'immutable' for variables. I'm curious, could you elaborate a bit on this? I skimmed through the page on