On Thu, May 12, 2016 at 1:19 AM, Larry Garfield <la...@garfieldtech.com>
wrote:

> On Mon, May 9, 2016, at 10:21 PM, Stanislav Malyshev wrote:
> > Hi!
> >
> > > |> seems like a common symbol to use, but it admittedly does look a
> >
> > So, usage in one semi-obscure language (F#) and one completely obscure
> > one (Elixir) - Clojure doesn't use |> - and one proposal for Javascript
> > now qualifies for "common". And that counting the fact that neither of
> > them actually uses the worst part of proposed syntax - magic variable $$.
> > --
> > Stas Malyshev
> > smalys...@gmail.com
>
> If the issue is $$ feels too Perl like, what is the alternative?  Is
> there another way to chain methods cleanly?
>
> In a sense, what we're really talking about here is continuations.
> Continuations (over-simplified) are a clean way of setting up "run this
> function, pass its result to this function, pass its result to this
> function, etc."  That makes composition really easy.  |> is essentially
> a continuation syntax.  The $$ is to work around the fact that PHP
> function can have an arbitrary number of parameters, whereas
> continuations work best with single-parameter functions.
>
> Of course, with currying any multi-parameter function can be reduced to
> a series of single parameter functions.  So what if we were to limit the
> concurrency syntax to single-parameter functions?  And if you want to
> reduce a multi-parameter function to a single parameter function, yay
> closures.
>
> Would that limitation help or hinder?
>
> Either way, I firmly believe that more functional-friendly capabilities
> like continuations, promises, etc. are a direction that PHP needs to
> move, and syntax in that direction is valuable.


I wonder if it's possible to use $$ only when it's necessary to pass in the
argument positionally, that is, if it's not used on the right hand side,
it's passed in magically as the first argument, otherwise it's passed in
wherever the $$ (or whatever other placeholder you want) is used.

_OR_ we just prepend it to the argument list used on the RHS. I noticed
that Closure also have ->> for passing in the argument last, vs -> for
first. I'm not sure I would like to have |>> for example.

I think that $$ as a positional placeholder gives us the most flexibility.
$$ is super easy to type, apparently is possible with little conflict to
existing syntax, etc.

I'm +1 on |> and $$.

- Davey

Reply via email to