digitalmars.D.bugs - [Issue 8075] New: Optional parameters should be able to refer to previous parameters
- d-bugmail puremagic.com (20/20) May 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8075
- d-bugmail puremagic.com (17/17) May 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8075
- d-bugmail puremagic.com (7/7) May 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8075
http://d.puremagic.com/issues/show_bug.cgi?id=8075 Summary: Optional parameters should be able to refer to previous parameters Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: wfunction hotmail.com --- Comment #0 from wfunction hotmail.com 2012-05-09 18:11:13 PDT --- void process(R)(R items, size_t maxCount = items.length) { } unittest { process([1, 2, 3]); } It would be great if this worked. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8075 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy yahoo.com --- Comment #1 from Steven Schveighoffer <schveiguy yahoo.com> 2012-05-10 04:58:18 PDT --- I really like this idea. But there must be a provision that the expression isn't substituted wholesale. For instance, your example should not expand to: process([1, 2, 3], [1, 2, 3].length); which allocates *twice*, the second time just to get the length. It should really expand to this: auto items = [1, 2, 3]; process(items, items.length); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8075 --- Comment #2 from wfunction hotmail.com 2012-05-10 15:12:23 PDT --- Also, not sure if this is a related or a separate issue, but we should also be able to refer to "this" object inside the optional arguments... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2012