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:

x.len()

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 
method).

- 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: 
http://www.kr41.net/2013/08/27/uniform_function_call_syntax_in_d.html
- Second, an article from the Walter Bright, the creator of D: 
http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394

Has this been discussed or proposed before? I found PEP's 443 and 3124, which 
provide a form of function overloading, but not reordering.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to