Allow version (assert) like version (unittest). #1099

Merged
merged 1 commit into from Sep 2, 2012

Conversation

Projects
None yet
3 participants
Owner

andralex commented Sep 2, 2012

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;

appropriately. Thoughts?

Owner

andralex commented Sep 2, 2012

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.

andralex merged commit 866eaef into dlang:master Sep 2, 2012

Member

alexrp commented Sep 2, 2012

I think that's the most reasonable approach. Preferably D_ArrayBoundChecks or so.

Release mode can be detected by doing something like:

debug {}
else
{
}

Though that isn't pretty. But we have the same problem when you want to check for the inverse of some version condition...

Owner

andralex commented Sep 2, 2012

Good point, thanks. I think debug/else is reasonable. So D_ArrayBoundChecks is the remaining issue.

Contributor

Poita commented Sep 2, 2012

debug/else doesn't work. Compiling with no flags isn't debug.

dmd -debug (version == debug)
dmd -release (version != debug)
dmd (version != debug)

Member

alexrp commented Sep 2, 2012

Well, that is certainly a mess. Why doesn't DMD just default to -debug if neither -debug nor -release are passed?

Contributor

Poita commented Sep 2, 2012

Because you don't usually want full debug. Full debug adds extra error checking that you don't usually want for general development.

Member

alexrp commented Sep 2, 2012

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...

Owner

andralex commented Sep 2, 2012

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment