[Issue 7417] New: One-definition rule for version specification -	allow version expressions
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Feb  1 03:51:35 PST 2012
    
    
  
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: nobody at puremagic.com
        ReportedBy: clugdbug at yahoo.com.au
--- Comment #0 from Don <clugdbug at 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: -------
    
    
More information about the Digitalmars-d-bugs
mailing list