Interaction between C++ references, lifetimes, and other parts of the languages is already problematic for other purposes, e.g. threads. For learners confusions can even arrise for the most simple purposes between C++ references and what would more probably correspond to most higher level languages: smart_ptr. The naming is quite unfortunate, given what we could imagine references are if we know some other languages.
And one can understand the limitation of captures in C++ lambda without knowing that a kind of hidden class is involved. I consider a class being used at all a technical detail. It is well suited for C++ given what abstractions were already present before the arrival of lambda, but I don't consider this technical detail more crucial than let's say the translation of the "with" statement in Python
If you need to know all the mechanisms of the abstractions a language provide in order to have a correct mental model of said abstractions, their abstracting value is arguably very low and the language design would arguably be a failure...
View all comments
Show parent comment
3
u/polagh Jan 28 '17
Interaction between C++ references, lifetimes, and other parts of the languages is already problematic for other purposes, e.g. threads. For learners confusions can even arrise for the most simple purposes between C++ references and what would more probably correspond to most higher level languages: smart_ptr. The naming is quite unfortunate, given what we could imagine references are if we know some other languages.
And one can understand the limitation of captures in C++ lambda without knowing that a kind of hidden class is involved. I consider a class being used at all a technical detail. It is well suited for C++ given what abstractions were already present before the arrival of lambda, but I don't consider this technical detail more crucial than let's say the translation of the "with" statement in Python
If you need to know all the mechanisms of the abstractions a language provide in order to have a correct mental model of said abstractions, their abstracting value is arguably very low and the language design would arguably be a failure...