Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 2, 2012
Merged

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

merged 1 commit into from
Sep 2, 2012

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Sep 2, 2012

@andralex
Copy link
Member

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?

@andralex
Copy link
Member

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 added a commit that referenced this pull request Sep 2, 2012
Allow version (assert) like version (unittest).
@andralex andralex merged commit 866eaef into dlang:master Sep 2, 2012
@alexrp
Copy link
Member Author

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

@andralex
Copy link
Member

andralex commented Sep 2, 2012

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

@Poita
Copy link
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)

@alexrp
Copy link
Member Author

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?

@Poita
Copy link
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.

@alexrp
Copy link
Member Author

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

@andralex
Copy link
Member

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants