D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1781 - Conditional Compilation - debug ( Integer ) is to restrictive
Summary: Conditional Compilation - debug ( Integer ) is to restrictive
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 enhancement
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2008-01-11 04:18 UTC by danijans03
Modified: 2019-08-26 13:38 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description danijans03 2008-01-11 04:18:55 UTC
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.
Comment 1 bearophile_hugs 2010-05-12 03:01:50 UTC
There is also this syntax:
debug ( Identifier )

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

To be compiled with:
-debug=MEDIUM