Design Principles Behind Smalltalk
cs.virginia.edu
cs.virginia.edu
I've been thinking about an OO language where there is no subclassing. However, you do have protocols (interfaces) and super-protocols. This might even allow for full type inference.
For example
- (void)printValue:(Foo *)foo {
NSLog(@"%@", [foo stringValue]);
}
it doesn't matter that printValue: says it wants a Foo, you can still pass it an NSTextField all the same.This gets really fun when you start using -respondToSelector: Now we can do:
- (void)printValue:(Foo *)foo {
if ([foo respondsToSelector:@selector(stringValue)])
NSLog(@"%@", [foo stringValue]);
}
This sort of thing is used throughout Cocoa (although these days explicit protocols are replacing it). It's difficult to do in C++, which is one of the reasons why C++ UI toolkits are so cumbersome.