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

Recursion detected does not make sense #20

Open
PaulHeisterkamp opened this issue Aug 14, 2019 · 4 comments
Open

Recursion detected does not make sense #20

PaulHeisterkamp opened this issue Aug 14, 2019 · 4 comments

Comments

@PaulHeisterkamp
Copy link

Recursion detected: I think this rule do not make sense because a modern programming language it should be possible to use recursions. The argument for banning recursions is "...we had recursion related problems in production environments to often...". For me this is also no agreement for putting the recursions on a "black list". I think it would make more sense to add runtime checks to restrict the recursion depth.

@PalleAgermark
Copy link

I agree. If you need recursion, you'll now have to implement solutions "clever" enough to go under the radar of the App Checker. Probably with even more interesting recursion bugs as a result. Recursion requirements wont go away. Maybe Microsoft could give us some sort of framework to use to ensure that endless recursions are avoidable.

@dickwenning
Copy link

In my old dayes (1990's) on Telefoon switches software we also banned recursion,
the risk of non ending loop is there with adition high CPU usages.

@AndreasHassing
Copy link

AndreasHassing commented Oct 24, 2019

This discussion is interesting 😊, thanks for bringing it up.

@PaulHeisterkamp: how would you detect runaway recursions? We already have some protection we can toggle on for environments that get stack overflow crashes a lot, but it comes with a performance penalty. Should all environments pay that price so developers can use recursions without warning?

@PalleAgermark: what kind of framework? The only thing that comes to my mind is what F# does with the rec keyword, but that might not work for us since the order of method declarations does not matter in X++ - so how can we know for sure method A does not call method B somewhere down the line (when method B calls method A), without spending a lot of time and memory during compilation.

One idea could be to disallow recursion (where detected) unless a method is decorated with a [Recursive] attribute. This, in turn, should add code to the method to ensure the recursion depth is tracked and only allowed to some upper bound. Mutual/circular recursion (which is most often the top offender) I think is hard to detect, though.

@PaulHeisterkamp
Copy link
Author

@AndreasHassing I would vote for the [Recursive] attribute to reduce the effort for checking recursion depth. In addition to that I would limit to a "static" number e. g. 100

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

4 participants