Thoughts about in contract inheritance

Stewart Gordon smjg_1998 at yahoo.com
Wed Feb 29 16:49:57 PST 2012


On 29/02/2012 20:45, Timon Gehr wrote:
> On 02/29/2012 09:30 PM, Stewart Gordon wrote:
<snip>
>> But I can see what you really mean: the spec of what inputs to an
>> overridable function are legal and what inputs are illegal is part of
>> the API.
>>
>> Stewart.
>
> An input that is not legal is illegal and vice-versa.

Well, obviously, but what's your point?

Maybe the question is of what's meant by "part of the API".  I'd made out that we were 
talking about what a user of the library would be right to rely on.  That a given function 
call is legal normally falls under that category.  But if you call a function, you will 
call it with legal input, so probably won't care about some other input that is illegal.

Of course, if the function in question admits alternative implementations through 
virtuality, then you're going to get implementations relying on the restrictions on input, 
so the illegality of some calls to the function becomes part of the API.  But that doesn't 
magically render "the fact that a given function call is legal is part of the API" and 
"the fact that a given function call is illegal is part of the API" logically equivalent 
statements.

Or does some of your code rely on the fact that a given library class has no method with a 
given name?

Stewart.


More information about the Digitalmars-d mailing list