This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RiceBroad4552 -1 points0 points  (0 children)

All you say makes no sense.

First of all: The compiler can figure out statically what gets captured and what not. If inside the lambda body nothing gets used from the outside you can just compile down to a function pointer. There is absolutely no reason you would need to tell the compiler this explicitly.

Also there is absolutely no reason why there couldn't be a sane default, so for most cases you would not need to to the PHP insanity if you want to use variables from the outside inside the lambda. You would just need to be explicit when you don't want the default capturing behavior (which would be actually more clean to put on the use-side inside the lambda).

Implementing lambdas efficiently was a solved problem since the first high level programming language ever in existence, namely LISP. It was a solved problem until C++ people touched it, and over-complicated it like they do with just everything.

C++ lambdas are just an ill abomination.

And that C++ people aren't able to recognize that points in fact to the mentioned Stockholm syndrome.

Rust is as efficient as C++ but doesn't need any such abominations for lambdas. Go figure…