Re: Pipe Operator v2

From: Date: Thu, 21 Jul 2016 12:39:13 +0000
Subject: Re: Pipe Operator v2
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-94611@lists.php.net to get a copy of this message
This is a great idea in general, but I think that this kind of operator is not the ideal (expect for $$ that seems very good). Some possibilities to think about: |> (as suggested) seems strange and not very clear, mainly in linear calls --> can be too long, but can make more sense or continuing, but can confuse with simple -> $> seems like terminal, but can tell like "keep this root-variable and run it", bad for linear too <- is short, maybe can tells "call it and return to root-variable", in linear can be confused with "minus" minus operation ($x<-a()) => is short, but can be confused why array syntax, but good for linear .. (like Dart) is short, but can be confused why a (double?) concat, not seems PHP in general (but still a good option) Another option is make calls without define an operator, the problem is that can be not clear or then cause break changes (very bad for linear). Or defining a new keyword, but it can be exhaustive or reduce readability. Should be think about the linear readability too, for instance: $object->a()->b()->c() vs. $object|>a()|>b()|>c(). Examples: http://pastebin.com/rguUSxDr It can works to avoid matroska (as initial suggestion) but for objects too. PHP should identify if this operator is used over object or other type (that allows the use of $$). The problem is it can be confused: are you executing an object method or another function with the object? Like in: $clockObject |> setHour(12) |> is_string($$). 'is_string' is from Clock or PHP native function? Example: http://pastebin.com/t79kjaHQ

« previous php.internals (#94611) next »