> I can get assistance on a better implementation than my paltry skills were > able to manage before. (And if we can collectively make a stronger argument > for it.)
Well sadly that definitely cannot be me. As I just started to get on board with internal development. But I am more than excited and ready to help wherever I can. > $a = $obj->getConfig() > |> array_map($$->getId(), $$) > That is, using $$ to refer to "the value passed from the previous pipe" and > "make a closure whose argument is an object that we can then operate on". > Both of those are "obvious" users of $$, but when combined... it's confusing > to me which $$ is which, at least. Yes, I mixed up stuff. > That's one of the reasons I preferred partial function applications to have > their own separate syntax and RFC, and have pipes work on just > closures/callables directly. It neatly sidesteps this issue, and leaves $$ > free for the "closure that takes an object" syntax. > So the above would become something like: > $a = $obj->getConfig() > |> array_map($$->getId(), ?) > > Which is less ambiguous. What if it's not an object? Let's say an array of arrays? Or an array of value objects with public properties, and I don't want to call ->getId(), instead just ->id? ``` $a = $obj->getConfig() |> array_map($$["id"], ?) ``` Personally I would keep the $$ for the pipe. Why: 1. Hacklang has it that way. 2. I think a lot of people already associate it with this purpose. 3. I feel that $$ more has “something previously” or “something same”. As it would be passed through the pipe I feel it fits more. 4. Maybe the following example is silly but ``` $foo = “stuff”; $baz = “foo”; $items = getConfig() |> array_map($$[$$baz], ?) // what is $$baz in this case? var_dump($items); // what would this be? ``` Sure this could be done if the T_BLING is restricted for the pipe operator. But I feel, having it restricted there leaves less opportunity for sloppy code. Anyways, as you just wrote, these are all individual, separate language features, but still have to be designed together. So to sum-up, I would keep the T_BLING for the pipe operator. And how do you feel about any of the following? ``` $items = array_map(array $value => $value->getId(), $items); // A shorter anonymous function shorthand // As a variable all would lead to syntax error, but here as - whatever we name it - it would work // Just $ $items = array_map(User $->getId(), $items); $items = array_map(array $["id"], $items); // Or $@ / $: $items = array_map(User $@->getId(), $item); ``` These could work well with pipe operators. > in my mind, these are all separate language features (PFA, pipes, and lenses) > that have their own distinct uses, but they need to be designed in tandem so > that they mix well together. Sadly, PHP doesn't do well with that kind of > mini-roadmap. :-( -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php