Mike Austin's Blog

Monday, November 27, 2006

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) stream
{
// 'stream' supports read() and write()
}
I'm not quite sure how optional methods in Obj-C protocols work, because a protocol by definition states what methods it supports. Optional requirements? :)

52 Comments:

Post a Comment

<< Home