Ad-hoc protocols
Objective-C has the notion of protocols, which enable an object to say that it supports a certain set of methods. And Obj-C 2.0 extends on that with optional methods and concrete protocols. What about supporting ad-hoc protocols? For example:
- foo: (@read, @write) streamI'm not quite sure how optional methods in Obj-C protocols work, because a protocol by definition states what methods it supports. Optional requirements? :)
{
// 'stream' supports read() and write()
}