const/immutable member functions

foobar foo at bar.com
Mon Jan 24 15:40:28 PST 2011


so Wrote:

> > This "problem" happens because D belongs to the C-family of languages  
> > which puts the return type _before_ the function name.
> 
> It has nothing to do with being a C-family language. C/C++ don't have  
> this, and the rules are perfectly clear.
> It is just unifying two or more unrelated things in one syntax for the  
> sake of consistency (and compiler complexity?).

C++ style aka Yoda style:
1. public double func(int input) const; 
2. const double func(int input); 
3. const double func(int input) const; 

VS. 
hypothetical left-to-right style:
1. public const func (int input) -> (double); 
2.  func (int input) -> (const double);
3. const func (int input) -> (const double); 

Which ordering makes for a more natural read?


More information about the Digitalmars-d mailing list