www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8985] New: __parameters tuple string strips off the scope of default args


           Summary: __parameters tuple string strips off the scope of
                    default args
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: turkeyman gmail.com

--- Comment #0 from Manu <turkeyman gmail.com> 2012-11-08 14:50:57 PST ---
import std.traits;

struct Vector
    float x,y,z,w;
    immutable Vector one = Vector(1,1,1,1);

void func(int x = 10, ref const Vector v = Vector.one);

static if(is(typeof(func) PT == __parameters))
    pragma(msg, PT);

Output: (int x = 10, ref const(Vector) v = one)

Notice: 'one' has had the 'Vector.' removed from infront, it is no longer a
valid identifier.
It'd be nice if that string would rather produce a fully justified name: (int x
= 10, ref const(Vector) v = modulename.Vector.one)
This way it would remain a valid identifier, and usable in mixins.

Walter has some reservations about making this change, concerned it may be a
breaking change.

I argue that the only reason anyone would want to use this string is for
something like a mixin, and encouraging people to write a large system around
this functionality to parse the string and put 'Vector.' back on is not
something you want to stick with. (this is what I was tempted to do, but
dismissed it on basis of insanity)

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 08 2012