digitalmars.D.bugs - [Issue 5175] New: Add a way to get parameter names to std.traits
- d-bugmail puremagic.com (23/23) Nov 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5175
- d-bugmail puremagic.com (34/35) Jan 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=5175
http://d.puremagic.com/issues/show_bug.cgi?id=5175 Summary: Add a way to get parameter names to std.traits Product: D Version: unspecified Platform: Other OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com PDT --- You can use std.traits.ParameterTypeTuple!() to get the types of the parameters to a function, but there is not currently a way to get the names of the parameters. Apparently, this would be useful for creating bindings with other programming languages, so it should be added. It's discussed in this question on stackoverflow: http://is.gd/gLeNf So, we should have something like std.traits.ParameterNameTuple!() which gives the names of a function's parameters. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5175 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 19:37:08 PST --- Well there is now __parameters, but this gives out both the types, param names, and default values: void test(int x, int y = 1) { } template ParameterTuple(alias func) { static if(is(typeof(func) P == __parameters)) alias P ParameterTuple; else static assert(0); } void main() { pragma(msg, ParameterTuple!test); }(int x, int y = 1)I would personally like to wrap ParameterTypeTuple, ParameterStorageClassTuple, and provide a single GetParameters template which would return a tuple of these struct objects: struct Parameter(Type, alias DefVal) { ParameterStorageClass stc; Type type; string name; alias DefVal defaultValue; } It's questionable how doable this is but it would make the API easier to use. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 22 2013