<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 15 Aug 2024 at 21:05, Jonathan M Davis via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thursday, August 15, 2024 4:34:49 AM MDT Richard (Rikki) Andrew Cattermole <br>
via Digitalmars-d wrote:<br>
> On 15/08/2024 9:05 PM, IchorDev wrote:<br>
> > Yeah, I feel you. When I first started writing in D I’d also use `const<br>
> > ref`, but I agree that interleaving the storage class and the type is<br>
> > not right. I’m not alone in having started with `const ref`, and then<br>
> > having moved to using `ref const` as I understood the language better.<br>
> > I think part of the reason some gravitate to `const ref` because of<br>
> > ignorance when coming from C++, but I never used C++ because I was aware<br>
> > of its reputation. Instead, I found the ordering to violate English<br>
> > adjective ordering. `ref const T` sounds wrong in the same way as ‘red<br>
> > big balloon’. In English you can have a ‘constant reference integer’ but<br>
> > not a ‘reference constant integer’; it sounds like an imperative<br>
> > instruction.<br>
><br>
> +1<br>
><br>
> Perhaps not an error in practice, but a warning is certainly warranted<br>
> as it shows a lack of understanding in the language.<br>
<br>
Not really. Unless you actually need to use parens, const ref is perfectly<br>
valid, and I really don't see the problem.</blockquote><div><br></div><div>Really? I just explained it... you weren't even mildly persuaded?<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> I understand const perfectly fine<br>
and yet I always use const ref unless I have to use ref const, because ref<br>
const is just plain ugly -</blockquote><div><br></div><div>Subjective; and I feel the opposite way. However there is definitely one that is <i>more correct</i>, and it's undeniably the way I argue here.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> and it doesn't add any value except in cases<br>
where you can't use it anyway.<br></blockquote><div><br></div><div>I reckon there's immense value in representing the language in such a way that you can learn and feel the semantics by osmosis. `storage class` seems to be a complex matter that takes a long time to get a proper feel for even if you do read the spec. I am absolutely convinced that for a majority of newcomers, seeing type declarations separated into distinct parts helps to separate the concepts.<br></div><div><br></div><div>I have had detailed conversations stimulated by this exact confusion on many occasions... writing `const ref` gives people the wrong impression every time and a long detailed conversation necessarily follows, and it's a conversation that's never flattering towards D. In my experience, it's one among a series of small but meaningful-in-aggregate such psychological blows against D whenever I introduce it to new people. It's among a subtle suite of issues that undermine people's confidence that D knows what it's doing very early on.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I agree that having function attributes be legal on both the left-hand and<br>
right-hand side of a function is problematic, but I see no value in forcing<br>
their order, and in general, making their order matter is just going to be<br>
annoying to deal with.<br></blockquote><div><br></div><div>I see no value in <i>not </i>forcing their order. I made my case, apparently you weren't persuaded... make your case, I'd like to hear it. Something like "yeah, I just kinda like to mix it up however I want" is definitely not going to persuade me.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Either way, warnings are a terrible idea in general. When you're dealing<br>
with warnings, you end up in one of two situations:<br>
<br>
1. You ignore the ones that don't actually need fixing, in which case, the<br>
number of warnings will eventually grow to the point that you can't actually<br>
see the ones that matter, making the warnings borderline useless.<br>
<br>
2. You "fix" all of the warnings so that none are buried, meaning that<br>
you're effectively treating all warnings as errors even though many of them<br>
don't actually indicate a real problem, making the difference between<br>
warnings and errors effectively pointless.<br>
<br>
The fact that dmd even has warnings was a huge mistake IMHO. Either they<br>
should be errors, or they should be left up to linters, and we should avoid<br>
adding new warnings like the plague (honestly, I think that we should really<br>
consider getting rid of them entirely).<br>
<br>
And warnings in D are even worse than they are in most languages, because -w<br>
is unfortunately a thing, meaning that adding a warning can result in an<br>
error, which can not only make perfectly valid code cease to compile with a<br>
compiler update, but it affects conditional compilation, because it affects<br>
checks for whether a particular piece of code compiles, which is used<br>
_heavily_ in templated code. So, you can end up with template constraints<br>
which suddenly fail - or even worse, the code ends up compiling but using a<br>
different branch, and you silently end up with worse performance (or maybe<br>
even altered behavior in some cases).<br></blockquote><div><br></div><div>
<div>Yes, totally agree; definitely not a warning. Either a spec change, or a
convention should be established in the major libraries so people see a
consistent pattern they will follow in their own code.<br></div><div><br></div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
If you want to have a linter of some kind warn about random stuff like const<br>
ref, then I really don't care, but adding anything of the sort to the<br>
compiler is a terrible idea.<br>
<br>
- Jonathan M Davis<br>
</blockquote></div></div>