Re: Function parameters UDAs

2019-06-10 Thread Machine Code via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 02:24:49 UTC, Adam D. Ruppe wrote: On Tuesday, 11 June 2019 at 02:04:13 UTC, Machine Code wrote: I also, quite disappointed how UDAs doesn't work with enums. I end up using struct + enum to simulate that, sometimes it's quite a work. They do now... struct foo {}

Re: Function parameters UDAs

2019-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 02:04:13 UTC, Machine Code wrote: I also, quite disappointed how UDAs doesn't work with enums. I end up using struct + enum to simulate that, sometimes it's quite a work. They do now... struct foo {} enum Foo { @foo a } void main() {

Re: Function parameters UDAs

2019-06-10 Thread Machine Code via Digitalmars-d-learn
On Wednesday, 14 November 2018 at 16:28:19 UTC, Radu wrote: Looks like that there is no easy way to extract a function parameters UDA list. The following: ``` import std.traits; struct s { string foo; } void foo(@s("aaa") int a, bool x); void main() { alias P = Parameters!foo; enum

Re: Function parameters UDAs

2019-06-10 Thread ag0aep6g via Digitalmars-d-learn
On 11.06.19 01:12, Johannes Loher wrote: I would like to iterate over all parameters of a function using static foreach and then process each parameter's UDAs. But by using static foreach on the parameter tuple, slicing it is not possible anymore, so the suggested workaround does not work in

Re: Function parameters UDAs

2019-06-10 Thread Johannes Loher via Digitalmars-d-learn
On Wednesday, 14 November 2018 at 18:05:55 UTC, Adam D. Ruppe wrote: On Wednesday, 14 November 2018 at 16:28:19 UTC, Radu wrote: Looks like that there is no easy way to extract a function parameters UDA list. Indeed, the only way I can find is kinda crazy: --- void foo(int f, @("test")

Re: Function parameters UDAs

2018-11-14 Thread Radu via Digitalmars-d-learn
On Wednesday, 14 November 2018 at 18:05:55 UTC, Adam D. Ruppe wrote: On Wednesday, 14 November 2018 at 16:28:19 UTC, Radu wrote: Looks like that there is no easy way to extract a function parameters UDA list. Indeed, the only way I can find is kinda crazy: --- void foo(int f, @("test")

Re: Function parameters UDAs

2018-11-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 14 November 2018 at 16:28:19 UTC, Radu wrote: Looks like that there is no easy way to extract a function parameters UDA list. Indeed, the only way I can find is kinda crazy: --- void foo(int f, @("test") string s) {} void main() { static if(is(typeof(foo) Params ==

Function parameters UDAs

2018-11-14 Thread Radu via Digitalmars-d-learn
Looks like that there is no easy way to extract a function parameters UDA list. The following: ``` import std.traits; struct s { string foo; } void foo(@s("aaa") int a, bool x); void main() { alias P = Parameters!foo; enum udas = __traits(getAttributes, P); pragma(msg, udas); }