Thread overview
struct sta­tic ini­tial­izer method apply to UDA
Dec 06, 2018
learnfirst1
Dec 06, 2018
Basile B.
Dec 06, 2018
Radu
Dec 06, 2018
learnfirst1
December 06, 2018
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;
}



December 06, 2018
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.
December 06, 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.
December 06, 2018
On Thursday, 6 December 2018 at 12:50:34 UTC, Radu wrote:
> On Thursday, 6 December 2018 at 11:09:47 UTC, Basile B. wrote:
>
> Which would be a real nice feature to have.

this is what I need, I guess I has to wait.