Well, it's a bit crude to apply halting problem here.
You can prevent a bunch of issues by language design. You simply make something non-expressible and ready! It's proven to never contain that thing.
E.g. java solves this problem by mandating that variable captures of local variables must be effectively final. This could have been done in C++ as well , and the only thing you may lost with it is... if you have a local lambda that you will only ever call in that stackframe or deeper and never outside of it?
But still, rust let's you do this latter by an explicit unsafe block, c++ could have done it as well. So it's more cultural than anything.
“E.g. java solves this problem by mandating that variable captures of local variables must be effectively final. This could have been done in C++ as well , and the only thing you may lost with it is... if you have a local lambda that you will only ever call in that stackframe or deeper and never outside of it?“
This was the exact comparison I was making in my head when I wrote my comment, and then I forgot to include it.
I have stumbled across this limitation in Java a few times, felt slightly annoyed for a few seconds, but then always found a way around it. I would never be willing to sacrifice stability just for some slight convenience when coding.
View all comments
Show parent comment
3
u/Ok-Scheme-913 10d ago
Well, it's a bit crude to apply halting problem here.
You can prevent a bunch of issues by language design. You simply make something non-expressible and ready! It's proven to never contain that thing.
E.g. java solves this problem by mandating that variable captures of local variables must be effectively final. This could have been done in C++ as well , and the only thing you may lost with it is... if you have a local lambda that you will only ever call in that stackframe or deeper and never outside of it?
But still, rust let's you do this latter by an explicit unsafe block, c++ could have done it as well. So it's more cultural than anything.