3 ms·
That's the capture-by-reference vs capture-by-value distinction in a nutshell, yes. Capture-by-value takes a snapshot of the value instantly, and stores it unt
by nrclark 5y ago
That's the capture-by-reference vs capture-by-value distinction in a nutshell, yes.
Capture-by-value takes a snapshot of the value instantly, and stores it until the block is executed.
Capture-by-reference waits to evaluate the variable until the block is executed.
Between the two, capture-by-reference is the least surprising behavior IMO. It acts like the deferred code is copy/pasted onto the end of the function.
Capture-by-value is the most flexible, and can also emulate capture-by-reference by using pointers. Any syntax should either support both, or only capture-by-value.