Would this be a useful construct to add to D? auto for constructor call.

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Jan 23 11:49:52 UTC 2024


On Tuesday, January 23, 2024 4:11:00 AM MST ryuukk_ via Digitalmars-d-announce 
wrote:
> On Tuesday, 23 January 2024 at 06:30:08 UTC, Jonathan M Davis
>
> wrote:
> > That being said, I expect that it would be pretty easy to write
> > a mixin to do something like that if you really wanted to.
> > Also, if you're simply looking to not have to name the type,
> > you could do
> >
> > dataGrid = new typeof(datagrid)(15);
> >
> > - Jonathan M Davis
>
> You like to turn off people before they get the chance to develop
> further, this is bad
>
> You should try more languages, it'll be eye opener
>
> ``dataGrid = new typeof(datagrid)(15);`` is both, verbose and ugly
>
> Besides, you seem to have missed this:
>
> https://github.com/dlang/DIPs/blob/e2ca557ab9d3e60305a37da0d5b58299e0a9de0e/
> DIPs/DIP1044.md
>
> https://github.com/dlang/dmd/pull/14650
>
> It could be expanded with structs/classes
>
> So your "it can't be done" argument is already wrong

I never said that it couldn't be done. I said that it goes against how
expressions and assignment in D normally work, so it's probably not a change
that would be accepted. And the DIP and PR that you linked to have been
rejected. If the OP wants to push for a change like this, then they can, and
they might get lucky, but I would expect it to be rejected.

Either way, there are ways to do something similar with what we already
have, so I pointed them out. While you might not like a solution like using
typeof, it is an option that someone can use right now regardless of what
improvements we get in the future.

- Jonathan M Davis





More information about the Digitalmars-d-announce mailing list