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

           Summary: One-definition rule for version specification - allow
                    version expressions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: clugd...@yahoo.com.au


--- Comment #0 from Don <clugd...@yahoo.com.au> 2012-02-01 03:51:32 PST ---
This enhancement adds a new syntax for version specifications, which would
allow us to eliminate the bird's nest of version statements that occurs when
code has a complicated version dependency.

The new syntax makes version specifications look like boolean variable
declarations:

version identifier = expression;

It would become illegal to reference a version identifier which hasn't been
declared. The spec already says that version declarations may only occur at
module scope; this new form of version specification would additionally be
disallowed inside version blocks (this enforces the one-definition rule).

version identifier = extern;
means that the identifier is externally specified (either on the command line,
or as a compiler built-in).

version VersionIdentifier = VersionExpression;

extern version VersionIdentifier;
// means this version is set from command line, or is a compiler built-in

VersionExpression:
     VersionExpression && VersionExpression
     VersionExpression || VersionExpression
    !VersionExpression
    ( VersionExpression )
        VersionIdentifier
        true
        false
        extern

version(A)
{
   version = AorNotB;
}
version(B)
{
}
else {
   version = AorNotB;
}

becomes:
version AorNotB = A || !B;

----
Note that this is backwards-compatible, it doesn't collide with the existing
syntax. To get the full benefit from it, though, we would need to eventually
disallow existing version specifications from being inside version blocks.
version = XXX; outside of a version block would be the same as version XXX =
true; so most code would continue to work.

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

Reply via email to