2 ms·
I think everything you say is explained correctly, just that you describe a very special fringe case. The variables in your `declare` block only need to exit du
by MarcusE1W 6y ago
I think everything you say is explained correctly, just that you describe a very special fringe case. The variables in your `declare` block only need to exit during the if, so this is one way to manage their lifespan.
In Ada as in almost every language you are well advised to have small functions with limited scope and then build on top of them. This would mean if you would declare your variables as normal part of a function the variables would have the lifespan of the function, and the function being small and to the point would also not be that long and you can avoid all the additional effort with `declare`.
I am not saying that there is no use for `declare` but it’s not needed that often or a big hassle in my view.
Ada is a bit more verbose than other languages and has one of the main aims to be readable on the basis that you write it once and read it many times.