enforce()?

Adrian Matoga epi at atari8.info
Mon Jun 21 11:15:12 PDT 2010


Leandro Lucarella pisze:
> Walter Bright, el 20 de junio a las 19:32 me escribiste:
>> Leandro Lucarella wrote:
>>> Why will you assume I'm so dumb that I won't use your
>>> interface correctly?
>> Windows has had major legacy compatibility issues because critical
>> third party applications misused the APIs.
>>
>> People *will* misuse your API, and you will get blamed for it. It's
>> unfair, but that's how it works.
> 
> Luckily I haven't used Windows for about 10 years now =)
> 
> It's really a shame that D will take the stupidity route.
> 
> PS: I don't know how windows work, but if calling the Windows API is
>     like going into kernel mode, and you can mess other processes, it
>     seems reasonable to do check every API call as if it were user
>     input, but if you're confined to your process, is really stupid.
> 

It was 15 years ago, at the times of 3.x and 95, when Windows behaved 
like that.

The problem applies not only to Windows, but any API you would imagine.
A common situation is when you need to do your job quickly using only 
some part of a library which otherwise you aren't going to study 
thoroughly, or you want only a proof-of-concept. And if your attempting 
to use something new to you, you do make mistakes, no matter how you are 
convinced yo do not.
If the API is defined not by documentation (which is often a tissue of 
lies, and hardly ever it's unambiguous), but by means of input checking, 
you have benefits in two fields: 1) developers of library had to think 
what they wanted to do, so library probably works, and it's less 
probable that its new versions will break the compatiblity, and 2) users 
of the library will be warned quickly, saving their time.

It's not about messing other processes. It's about saving your time, 
otherwise consumed by effects of common mistakes, misunderstanding the 
documentation, or working in a hurry. And your time costs much more than 
the time of bazillion argument checks.


More information about the Digitalmars-d mailing list