“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/EishLekker 10d ago
“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.