On Sun, May 8, 2016 at 11:45 PM, Stanislav Malyshev <smalys...@gmail.com> wrote:
>> Yep, that's exactly what "->" does.  It's just pointless syntactic
>
> No, not really. Calling method on an object is an universally accepted
> phrase in many languages.
>
I never said it wasn't.  I said it was pointless syntactic sugar.

> Moreover, there's no easy and more readable way to call methods in PHP,
> so -> is the best way to go.
>
But there are ways to implement "oop" with explicit data passage.
Ways which could have been leveraged in PHP3.  We don't use those ways
because it's a PITA and produces unreadable code.  Which is what
syntactic sugar is meant to alleviate.

> Moreover, calling methods is a very frequent operation, and any time you
> need it, regardless of what is the circumstance, you'd use ->
>
Calling functions, chaining the output of one into the next is also a
frequent argument.

> Neither of these is true for |>-$$ thing - it does not have any matches
> in any languages I can think of.
>
You lack imagination.  Here's three to get you started:

Elixir: 
http://elixir-lang.org/getting-started/enumerables-and-streams.html#the-pipe-operator
F#: https://msdn.microsoft.com/en-us/library/dd233229.aspx#Anchor_11
Clojure: https://clojuredocs.org/clojure.core/-%3E

And if they seem to obscure, how about this proposal for Javascript?
https://github.com/mindeavor/es-pipeline-operator


>> Oh, sorry, we were talking about the function version of ->, my
>> mistake.  That's a totally different thing.
>
> I'm sorry I didn't get what you meant here. "function version of ->"
> makes no sense to me - function version of -> is the function call itself.
>
$foo->bar() calls the bar() method invisibly passing $foo as its
similarly hidden $this argument.
$foo |> bar($$) calls the bar() method quite visible passing $foo as
its explicitly non-hidden first argument.

The pipe call is clear and easily traces, the object call requires
understanding OOP.  I'll grant that OOP is much more common, and
therefore generally understood by individuals who already know OOP (as
tautologous as that statement is).

-Sara

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to