From: Dave Thomas Date: 2002-02-07T00:18:10+09:00 Subject: Re: Subclassing vs Subtyping (partly OOP vs FP) Robert Feldt writes: > > 1. It could check that classes it was mixed in to defined the methods > > it needed. > > > Minor quirk: I often write includes on the top so needed methods not yet > defined?! I _think_ you can hook that, only performing the test when the class is added to the parent. ... > > class BTreeBag > > implements BagProtocol > Sure, doesn't sound too hairy. Might be some conflicts with a truly > dynamic philosophy (I want to add the needed methods later etc) but maybe > not a problem in practice. Exactly - but it's available for use when you want. I'm thinking more and more that a way of documenting a class's fundamental methods would be useful. For example, you want to overwrite IO so that output goes to an in-memory buffer. Which methods do you have to change. Certainly #write. But what about #putc? Is #putc implemented in terms of #write? No way to know unless you read the C source code. Similarly for Arrays. Is overriding [] and []= enough? (No :). Having ways of explicitly listing a protocol seems to be good sense, if only from a documentation perspective. Dave