Designated initializers to function argument

Steven Schveighoffer schveiguy at gmail.com
Fri Jul 28 11:47:20 UTC 2023


On 7/28/23 3:35 AM, IchorDev wrote:
> On Tuesday, 11 July 2023 at 17:43:43 UTC, Steven Schveighoffer wrote:
>> On 7/11/23 11:22 AM, Ki Rill wrote:
>>> On Tuesday, 11 July 2023 at 15:16:54 UTC, Ki Rill wrote:
>>>> apply(Appearance(color: BLACK, strokeWidth: 4)); // other fields are 
>>>> default initialized: strokeOpacity, fillOpacity,
>>
>> Yes, I was going to reply that v 2.103 has added (stealthily) named 
>> parameters *as a partial implementation*. Included in this is struct 
>> initializers, and constructors and functions that are *not* templates.
>>
>> If you are willing to use DMD 2.103 and above, you should be good.
>>
> 
> N-no way?! The spec makes no mention of them, is it really safe to use 
> them yet?

It isn't going away. I would wait a bit for libraries, because you don't 
want to force your users to require such a recent version of the 
compiler. Using it in an executable is fine.

-Steve


More information about the Digitalmars-d-learn mailing list