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

For loops #45

Closed
pepsiman opened this issue Jul 14, 2018 · 6 comments
Closed

For loops #45

pepsiman opened this issue Jul 14, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@pepsiman
Copy link

https://en.cppreference.com/w/cpp/language/for says that for loops are equivalent to while loops.

"The above syntax produces code equivalent to:

{
init_statement
while ( condition ) {
statement
iteration_expression ;
}
}"

@andreasfertig andreasfertig added the enhancement New feature or request label Jul 15, 2018
@andreasfertig
Copy link
Owner

Hello pesiman,

that's one finding I feared. Your are totally right that this is a valid expansion of a for-loop. I can remember a couple of times I explained this to students. I'm just unsure whether it is a good idea to transform all for-loops to while-loops. I always had options for that in mind. That you can choose for your needs which parts should be transformed.
I think I need more data on what people would like to see here.

@pepsiman
Copy link
Author

I was thinking that there's a sequence of transforms, and the user chooses where to stop.
Range based for -> for -> while -> if and goto.

@simonrenger
Copy link

Conceptual idea:
Maybe add an extra mode in there like in a way that the user can choose between how deep cppinsight shall go/ transform

@andreasfertig
Copy link
Owner

Hello @simonrenger,

extra mode like a command line option: -use-while-loops?

Andreas

@simonrenger
Copy link

@andreasfertig yes in that way and on the website than just a drop down menu or checkbox(s). I am sure there are other things than just while loops

@andreasfertig andreasfertig added WIP Work in progress and removed WIP Work in progress labels Mar 24, 2019
@andreasfertig
Copy link
Owner

Hello @simonrenger, @pepsiman,

ok that is what I have in mind. I will push a patch to introduce this functionality in C++ Insights. There will be options to C++ Insights -alt-syntax-for and one for #44. However, it will take some additional time to prepare the website with a drop down menu with checkbox(s). As web-dev is not my strong suite, contributions for the drop down checkbox menu are welcome.

Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants