[Issue 8985] New: __parameters tuple string strips off the scope of default args

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 8 14:50:58 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8985

           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 at puremagic.com
        ReportedBy: turkeyman at gmail.com


--- Comment #0 from Manu <turkeyman at 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: -------


More information about the Digitalmars-d-bugs mailing list