On Sun, May 1, 2016 at 4:05 AM, Larry Garfield <la...@garfieldtech.com>
wrote:

>
> In a way... Sara, this syntax feels like it's only one step removed from
> promises; if any of the chained steps involve IO, it becomes basically what
> promises are for.  Am I barking down the wrong tree, or is there something
> we could connect there?  (I don't mean "reject this in favor of promises",
> but more "is there something we can do here to be forward thinking, since
> lots of people want to see async in core PHP?")
>
>
If you had async/await, you could of course use |> to chain async
operations in an async function by using "await $$" in place of "$$" (since
$$ would be the Promise/Awaitable):

$ret = scandir_async($arg)
       |> array_filter(await $$, ...)
       |> ...


That's quite neat, IMO, and the features are still orthogonal.

You could introduce a new operator to combine the "|>" and "await", say
"a|>", but to add an operator just to combine two others would seem a bit
arbitrary.

You could also generalise |> as a monadic bind (with Promise as the monad
for asynchronicity) but I don't know how that would fit in PHP land without
a meaningful way to turn an expression into a closure. It could be added
later as something like "|>>" if need be.

Reply via email to