www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - pure member functions

I assume that if you declare a member function as pure, then all of its 
parameters - including the invisible this - are included in that. That is, if 
all of them - including the invisible this - have the same value, then the 
result will be the same.

I'm not quite sure way (perhaps because pure is very much a thing of functional 
programming rather than object-oriented programming), but I feel very weird 
marking a member function as pure. Is there really in point to it? Does it act 
the same as if it were a pure static function that had an explicit parameter
the object rather than the invisible this? If that's the case, then it would 
seem like it would be sensible to mark virtually every member function as pure. 
The few that would be unable to would likely be due to accessing globals, which 
is usually a no-no anyway.

Am I misunderstanding something here? Is there a reason _not_ to use pure on 
every member function that you can?

- Jonathan M Davis
Sep 18 2010