I don't even know why lambda realization is not the same as in javascript.

```
let action = function () {
console.log('hello');

return 1;
}

let fn1 = () => action();
console.log(fn1()); // calls hello(), returns 1, for me, not a best way,
could be read like "call action() then create function that returns result
of that call"

let fn2 = () => (action());
console.log(fn2()); // calls hello(), returns 1, common, short way

// what's this?
(() => ())(); // could look strange? no, its declaring unnamed function
that does nothing and returns nothing and calls it immediately.

let fn3 = () => { action(); }
console.log(fn3()); // calls hello(), returns undefined, common, short
without return

let fn4 = () => action;
console.log(fn4()); // returns function, very handy for Promises, that
start init function immediate on new call, so it wraps function to "task"
available to call it later somewhere, maybe in another promise
```

Why is the PHP implementation redesigned from scratch instead of using the
idea of the one that works?

ps. Guess, the discussion to change syntax that you cold rewrite with
single line:

```
// > what?
// fn() => $client->ping() ? null : null

// > that
// static function () { $client->ping(); }
```

Ahh, the main problem in fn() is exactly that you don't like.... `use`
statement)))) So long to write the `use` keyword.

Аnd you prefer the `js` implementation, which automatically uses the
current scope in your callback.

And you need something handy, that is allow create functions:
- with all variables (copy local state)
- with short syntax
- with return modes variety
- with return types and parameter types, if you need it

is more interesting, than talk about error collection that requires
rewriting half of the app

As I remember you say, you work on projects with a million lines of code
and you prefer correctness instead of simplification.

Why do you use short functions then? OOP awaits you.

Create a function that wraps function:
1. one function returns result (client.ping())
2. second one returns null|result (myclass.clientPingOrNull())
3. The third one catches the first one with a try catch to return the
result and return errors (myclass.tryClientPingOrNull())
4. then call that batch of correctness in your callback...

Sorry, couldn't resist myself

Reply via email to