On Monday, 3 November 2014 at 02:43:03 UTC, David Nadlinger wrote:
On Tuesday, 28 October 2014 at 08:29:22 UTC, Jonathan M Davis via Digitalmars-d wrote:
I see no reason to say anything about the alias syntax in the style guide.

Consistency, and thus less confusion/mental overhead.

I don't think that you'll be able to make a strong case for "Either it should be considered fine to use, or we should deprecate it." If we started with a clean slate today, there wouldn't be a good reason to include the old syntax. It is an outlier as we've generally moved away from C-style ordering of types/declarations, and also can't do inline templates. And if we agree that the new syntax is to be preferred – and it seems like except for you we pretty unambiguously do –, I don't see why we shouldn't put that out as an official recommendation.

Of course, breaking legacy code over this by deprecating the old syntax might ultimately not be worth it. I don't see how this can be construed as an argument against putting it in the style guide, however. In fact, if we planned to deprecate it anyway, this would rather be a reason _not_ to to bother with putting it in the style guide first.

To summarize why the new syntax is better than the old one:
- It's more straightforward for newcomers, its order is the same as for basic assignments. If you somehow find that unnatural like you've claimed earlier, then you've merely trained your brain to read alias assignments backwards compared to assign expressions.

- Arguably the new syntax also makes it easier to skim-read the code, as the most important part (the symbol introduced) is at the beginning of the line, not hidden after some potentially multi-line template instantiation. Granted, you might say that this is not very relevant, but I think you'd find it hard to argue that the syntax is _less_ readable.

- The new syntax also has the advantage that it allows to easily declare template aliases, for example:
---
alias Seq(T...) = T;
---

By the way, "using" is regularly recommended for use in C++11 and up now instead of "typedef" for much the same reasons (just look at the CppCon talks for some data points).

David

I agree with basically everything you said.

I only have one thing I want to say. The only reason the new syntax was introduced is because its an improvement on the old, it would never have been added otherwise. That alone should be reason enough for it to be prefered.

Reply via email to