www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1781] New: Conditional Compilation - debug ( Integer ) is to restrictive

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1781

           Summary: Conditional Compilation - debug ( Integer ) is to
                    restrictive
           Product: D
           Version: 1.015
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: danijans03 student.kau.se


It is currently not possible to write something like:

enum DebugLevel { LOW, MEDIUM, HIGH };
debug(DebugLevel.HIGH)
        Logger.writeDebug("");

I think it is to restrictive to only allow Integer. An enum could easily be
cast to an integer internally.

You could of course write something like:

const int DebugLevelLow = 0;
const int DebugLevelMedium = 1;
const int DebugLevelHigh = 2;
debug(DebugLevelHigh)
        Logger.writeDebug("");

But this isn't as elegant as using enums.


-- 
Jan 11 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1781


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement




-- 
Jan 18 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1781


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



There is also this syntax:
debug ( Identifier )

So you can use:
debug(MEDIUM)
    Logger.writeDebug("");

To be compiled with:
-debug=MEDIUM

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