DIP 1031--Deprecate Brace-Style Struct Initializers--Community Review Round 1 Discussion
IGotD-
nise at nise.com
Fri Feb 14 23:00:01 UTC 2020
On Friday, 14 February 2020 at 22:11:36 UTC, Steven Schveighoffer
wrote:
>
> An alias declaration is a declaration. It needs its own line
> before the expression use. This is unwieldy as well, further
> squirreling away the definition from the usage, requiring more
> lookup time.
>
> Promoting "just use an alias" means someone just "quickly" adds
> an alias to make the thing short:
>
> alias X = Vector2D!double;
>
> ... // some many lines later
>
> auto awsd = Moves!double(items: [X(x: 1, y: 0), X(x: 0, y: 1),
> X(x: -1, y: 0), X(x:0, y:-1)]);
>
> Leaving the reader scratching his head at where X comes from
> after looking up the Moves layout and not seeing it there. Even
> with the alias, repeating the type over and over is really an
> exercise in rote frustration.
>
> Especially when the compiler already knows how to figure this
> out without help (it already does this correctly with struct
> initializer syntax today).
>
> -Steve
Yes, typing in the type name quickly gets old for these kinds of
use cases. I previously asked if writing (x: 1, y: 0) would be
enough and the compiler would infer the type itself. With your
example not even auto(x: 1, y: 0) would be sufficient. As I see
it in order for this DIP to pass and retain the usability just as
before the compiler must infer the type just like with curly
brackets.
More information about the Digitalmars-d
mailing list