Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Capturing lambdas are no different from handwritten structures with operator() ("functors"), therefore it makes no sense castrating them.

Borrowing from stack is super useful when your lambda also lives in the stack; stack escaping is a problem, but it can be made harder by having templates take Fn& instead of const Fn& or Fn&&; that or just a plain function pointer.



Convenience is a difference in kind.

Like, I'm not god's gift to programming or anything, but I'm decently good at it, and I wrote a use-after-return bug due to a lambda reference last week.


Borrowing from the stack is definitely useful. I do it all the time, safely (truly safely), in Rust.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: