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

Enable conditional compilation #5

Open
starkos opened this issue Nov 9, 2017 · 3 comments
Open

Enable conditional compilation #5

starkos opened this issue Nov 9, 2017 · 3 comments

Comments

@starkos
Copy link

starkos commented Nov 9, 2017

I would like to have the ability to turn off the checks in certain conditions or areas of the code. Would you be open to a pull request that adds [Conditional("PRECONDITIONS")] to the methods, so they could be turned on and off by a define?

It would require all users to define the symbols of course, which isn't ideal.

@starkos starkos changed the title Enable condition compilation Enable conditional compilation Nov 10, 2017
@lecaillon
Copy link
Owner

Can you be more specfic please ?

What is your purpose for doing it ?
How a ConditionnalAttribute would help ?

@starkos
Copy link
Author

starkos commented Nov 14, 2017

I have some inner loop code, running on mobile devices, that needs to execute as quickly and efficiently as possible. During development, I would like the checks in place to catch logic errors. At runtime, I want to disable them, but only for these inner loop sections of code.

(And yes, I measured, and removing the checks makes a difference in performance and energy usage.)

If you add the ConditionalAttribute, it would then be possible to disable the checks for a specific code file with #undef PRECONDITIONS at the top of the file. Or actually, more like:

#if RELEASE
#undef PRECONDITIONS
#endif

Right now I have to put that ugly #if … #endif around all of the checks in those files, which is not ideal.

The downside to adding the attribute, as I mentioned, is that the checks will only be evaluated if you define PRECONDITIONS somewhere, i.e. in your project file.

Figured it didn't hurt to ask…

@ryancerium
Copy link

I think that's a great feature @starkos

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

No branches or pull requests

3 participants