August 08, 2020 [Issue 21138] New: Difficult to treat UDAs given to parameters. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21138 Issue ID: 21138 Summary: Difficult to treat UDAs given to parameters. Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: zan77137@nifty.com Function arguments can be given UDAs, but they are very difficult to treat. ---------------------------------------------------------- import std; template Temp1(alias params) { alias Temp1 = params; } template Temp2(params...) { alias Temp2 = params; } template Foo(alias f) { // OK1 alias params = Parameters!(f); pragma(msg, params); // (@(10) int, @(15) long) // OK2 pragma(msg, params[0..1]); // (@(10) int) pragma(msg, __traits(getAttributes, params[0..1])); // tuple(10) // NG1: Lack UDAs alias param2 = params[0]; pragma(msg, params[0]); // int //pragma(msg, __traits(getAttributes, params[0])); // Error // NG2: Error //pragma(msg, Temp1!(params)); // NG3: This is able to pass, but lack UDAs pragma(msg, Temp2!(params)); } void main() { alias X = Foo!( (@(10) int x, @(15) long b) => x ); } ---------------------------------------------------------- In NG1 and NG3, UDAs should not lack. NG2 should allow them to be passed to an alias parameter, as is possible in OK1. But maybe this should be considered separately from this issue. (Allow tuple to be passed to an alias template parameter) -- |
Copyright © 1999-2021 by the D Language Foundation