On 09-12-2021 21:11, Jordan LeDoux wrote:
Hello internals,
I last brought this RFC up for discussion in August, and there was
certainly interesting discussion. Since then there have been many
improvements, and I'd like to re-open discussion on this RFC. I mentioned
in the first email to the list that I was planning on taking a while before
approaching a vote, however the RFC is much closer to vote-ready now, and
I'd like to open discussion with that in mind.
RFC Link: https://wiki.php.net/rfc/user_defined_operator_overloads
Hi Jordan,
Thanks a lot for your work on this RFC! I like the direction this is going.
One thing that may be worthwhile looking into is the query builder use
case. I mentioned it before:
https://externals.io/message/115648#115771
Basically it would enable using plain PHP expressions in stead of
strings. So in stead of
$query->where('product.price < ?1')->setParameter(1, 100);
one could write:
$query->where(Price < 100);
Here Price is a class that represents a database column which has a
(static) overload of the '<' operator. The operator overload yields an
object representing a database expression, which gets passed to the
where() method.
In general I don't like this sort of clever construct which makes one
wonder what on earth is going on. The reason I do like this particular
use case is that it can simplify code and enable static analysis of
query expressions.
Now I'm not suggesting to support this creative use of operator
overloading in the current RFC. It may however be useful to consider if
this use case could be supported by a future RFC in a backward
compatible way. Perhaps the RFC could mention it as a possible future
extension.
Kind regards,
Dik Takken
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php