The language D has a feature called Uniform Function Call Syntax, which allows
instance methods to be resolved using function calls.
In Python terms, the call:
would first check if 'x' has a method 'len', and would then look for a function
'len', passing 'x' as the first argument.
The big wins are:
- the ability to override functions with more optimal class-specific
implementations. (Of course, len() is a bad example, since we already have a
way to override it, but there are other functions that do not have a special
- the readability of a.b().c().d() vs c(a.b()).d()
Here's a few links discussing the feature in D:
- First, a fairly gentle "this is cool" post:
- Second, an article from the Walter Bright, the creator of D:
Has this been discussed or proposed before? I found PEP's 443 and 3124, which
provide a form of function overloading, but not reordering.