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

           Summary: Allow scoped assignment of version and debug
                    statements
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Andrej Mitrovic <[email protected]> 2013-10-04 
07:36:56 PDT ---
-----
void foo() { }

void main()
{
    version = CALL_FOO;
    version (CALL_FOO)
    {
        foo();
    }

    debug = DEBUG_FOO;
    debug (DEBUG_FOO)
    {
        foo();
    }
}
-----

$ dmd test.d
test.d(5): Error: (condition) expected following version
test.d(5): Error: found '=' instead of statement
test.d(11): Error: found '=' instead of statement

Allowing this would mean the version/debug identifiers were valid inside the
scope of the assignment. Outside of main() a version(CALL_FOO) body would not
be entered. 

The workaround is use to use enums and static if:

-----
void foo() { }

void main()
{
    enum CALL_FOO = 1;
    static if (CALL_FOO)
    {
        foo();
    }

    enum DEBUG_FOO = 1;
    static if (DEBUG_FOO)
    {
        foo();
    }
}
-----

But it would be more convenient to allow the former version/debug syntax,
especially if we want to re-use existing version/debug identifiers.

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

Reply via email to