D versus Objective C Comparison

Sean Kelly sean at invisibleduck.org
Wed Feb 4 07:41:48 PST 2009


Chris R Miller wrote:
> Jacob Carlborg wrote:
>> Walter Bright wrote:
>>> Setting aside the technical issues for the moment, isn't that exactly 
>>> what inheritance is supposed to be good for?
>>
>> A few times I've had the need for this, I've always been able to solve 
>> the problem but it would have been easier with support for this. But 
>> to be honest I don't remember these problems right now, so perhaps 
>> it's not that important.
> 
> I think it has less to do with how often its needed and more to do with 
> how much more elegant the solution will be.
> 
> Just because I want to supply one example of where it's even appropriate 
> to use a category-pattern to extend a class' function table without 
> extending the class into a new type, I'll just spit out something I just 
> wrote in Objective-C.
> 
> ===== Short Story =====
> 
> I needed to search through a String (NSString) specifically to know 
> whether a character at a specific index is any one of a given set of 
> characters.  Rather than subclass NSString, I decided to make a category:
 > [snip]

Won't all of this be solved by the planned D2 feature of making these 
operations synonymous for all types?

void fn(T val);
T t;
fn(t);
t.fn();

Or are you saying that these added functions can actually access private 
data in the class?


Sean



More information about the Digitalmars-d mailing list