www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Function call syntax.


I used to be able to find cases that make "object.function(parameters)"  
syntax rather expressive comparing to the obvious alternative.
In a language without name resolution and namespace/module capabilities  
this still solves some problems.
But, in D, do we really need this? IMO this syntax suitable only for  
fields and properties.

3 cases:
1. fields and properties


2. function with no parameters.


3. function with parameters.

function(object, parameters);
object.function(parameters); // the only compelling argument against  
normal syntax.

D has UFCS, with its shortcomings.
I like it but IMO it solves a problem that shouldn't be in the language at  
the first place.
I know this is yet another religious thing for some but unifying function  
call syntax opens many doors to generic programming (no UFCS doesn't cut  

Using Opera's revolutionary email client: http://www.opera.com/mail/
Jan 05 2011