Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 06, 2018 struct static initializer method apply to UDA | ||||
---|---|---|---|---|
| ||||
my question is how to easy use struct static initializer 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 Re: struct static initializer method apply to UDA | ||||
---|---|---|---|---|
| ||||
Posted in reply to learnfirst1 | On Thursday, 6 December 2018 at 11:04:23 UTC, learnfirst1 wrote:
> my question is how to easy use struct static initializer 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 Re: struct static initializer method apply to UDA | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | 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 static initializer 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 Re: struct static initializer method apply to UDA | ||||
---|---|---|---|---|
| ||||
Posted in reply to Radu | 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.
|
Copyright © 1999-2021 by the D Language Foundation