rfc:user_defined_operator_overloads
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:user_defined_operator_overloads [2021/12/16 04:19] – Extra future scope jordanrl | rfc:user_defined_operator_overloads [2021/12/17 01:53] – Making operator callable jordanrl | ||
---|---|---|---|
Line 101: | Line 101: | ||
This is avoided by allowing the restrictions on operator names to be separated from the restrictions on function names. | This is avoided by allowing the restrictions on operator names to be separated from the restrictions on function names. | ||
- | === Non-Callable === | + | === Callable === |
- | Operand implementations | + | Operand implementations |
<code php> | <code php> | ||
- | // These all should result in an error | + | // These all will work normally |
+ | $op = ' | ||
+ | $callable = [$obj, ' | ||
+ | |||
+ | // Calls on the object variable | ||
$obj-> | $obj-> | ||
+ | $obj-> | ||
+ | $callable(1, | ||
+ | |||
+ | // Calls using call_user_func | ||
call_user_func([$obj, | call_user_func([$obj, | ||
+ | call_user_func($callable, | ||
+ | |||
+ | // This will error since + is not static | ||
call_user_func(' | call_user_func(' | ||
</ | </ | ||
- | They can be directly invoked with a Closure however. This is to fully support | + | They can be also be directly invoked with a Closure however. This fully supports |
<code php> | <code php> |
rfc/user_defined_operator_overloads.txt · Last modified: 2022/01/17 01:16 by jordanrl