[Issue 11172] New: Allow scoped assignment of version and debug statements

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 4 07:36:58 PDT 2013


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: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 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: -------


More information about the Digitalmars-d-bugs mailing list