Allow version (assert) like version (unittest).
That's great, I've also found myself in need for that. There are two other important flags that can't be detected programmatically: release mode and noboundscheck mode. But those are not associated with keywords. Any ideas on how we can address those? I guess the simple thing would be to have the compiler implicitly define
version = release;
version = noboundscheck;
I'll preemptively merge this because it's consistent with what we already do and enables doing something that wouldn't be otherwise possible. If core compiler devs you have a strong disagreement please apologize.
I think that's the most reasonable approach. Preferably D_ArrayBoundChecks or so.
Release mode can be detected by doing something like:
Though that isn't pretty. But we have the same problem when you want to check for the inverse of some version condition...
Good point, thanks. I think debug/else is reasonable. So D_ArrayBoundChecks is the remaining issue.
debug/else doesn't work. Compiling with no flags isn't debug.
dmd -debug (version == debug)
dmd -release (version != debug)
dmd (version != debug)
Well, that is certainly a mess. Why doesn't DMD just default to -debug if neither -debug nor -release are passed?
Because you don't usually want full debug. Full debug adds extra error checking that you don't usually want for general development.
I'm starting to think that this -debug/-release mess is not worth it. It's supposed to simplify things but it seems like for every new command line option/compiler feature we add, it becomes too hard to reason about what the three compilation modes actually do. It would be much simpler if there was fine-grained control of asserts, contracts, etc.
Well, whatever. In any case, I can't help but think that integrating something into the language to detect -debug/-release/nothing is going to be a mess that we're going to regret later...
@Poita: right, I forgot (though it's in TDPL...). @alexrp: I think now it's water under the bridge. Let's leave it asleep for now, but noboundscheck and assert are actually important.