On Sun, Jun 28, 2020 at 02:23:38PM -0000, marcone@email.com wrote:
Is possible some day add Uniform Function Call Syntax (UFCS) in Python like Dlang?
Example: https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs
That converts calls like:
a.fun()
to
fun(a)
I don't think that will be a good match for Python. In D, the compiler can decide at compile time:
a
has no fun
method;fun
;a
;and so convert the method call to a function call at compile time, with no loss of efficiency or safety.
But in Python, none of that information is available until runtime:
a
will have;fun
method;fun
;a
.So all of that would have to happen at run time. That means that using
UFCS would make slow code. The interpreter would have to try calling
a.fun()
, and if that failed with an AttributeError, it would then try
fun(a)
instead.
-- Steven