struct sta­tic ini­tial­izer method apply to UDA

Radu void at null.pt
Thu Dec 6 12:50:34 UTC 2018


On Thursday, 6 December 2018 at 11:09:47 UTC, Basile B. wrote:
> On Thursday, 6 December 2018 at 11:04:23 UTC, learnfirst1 wrote:
>> my question is how to easy use struct sta­tic ini­tial­izer 
>> method with UDA.
>>
>> Fake code:
>>
>> struct DbColumn {
>>          string name;
>> 	bool	unique ;
>> 	bool	signed ;
>> 	bool	nullable ;
>> }
>>
>> struct Order {
>> 	uint id;
>> 	
>> 	@DbColumn({ .nullable= true}) // not working
>> 	string order_id;
>>
>> 	@DbColumn({ :nullable= true}) // not working
>> 	string order_time;
>>
>> 	@DbColumn(nullable= true) // not working
>> 	string order_time;
>> }
>
> Looks like what you want is named parameters.

Actually he's looking for in-place struct initialization
https://github.com/dlang/DIPs/blob/b1283b455b635d7dcbc2c871d2aa47cc67190059/DIPs/DIP1xxx-sw.md

Which would be a real nice feature to have.


More information about the Digitalmars-d-learn mailing list