int nan

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Jun 28 10:47:05 PDT 2009


Simen Kjaeraas wrote:

>>>> But the beauty of the holy grail is that it's neither.
>>>
>>> While the ugliness of it is that it's both.
>>
>> Care to elaborate?
> 
> As has already been mentioned, one of the biggest problems with the holy
> grail is that it leads to capricious states of "possibly compilable".
> There are also bunches of examples in which it will not be able to
> deduce if it should compile or not, at least not without breaking
> modularity,

The modularity thing is a good point. I assume you're talking about
encapsulation. The designer of a function should make its definition
public. The stuff it requires and the stuff it guarantees. The stuff it
requires can be of the form of a logical precondition. The stuff it
guarantees could be, at the choice of the designer, the function body
itself or a logical postcondition (with access to the initial state of the
function). The postcondition is used if you want to encapsulate the
function implementation.

Remember that the definition should be known to the caller of the function
anyway, or why would he/she call it? Often this is in the form of
documentation, but ideally it would be in an assertion language the
compiler can understand.

> and even then, functions called from outside sources (dlls, 
> SOs, OS functions, compiled libraries, etc) will break the system.

You're right. If nothing is known about them, they must automatically
receive the weakest possible postcondition: true. Pretty much anything can
happen if you call them. However, it's acceptable for either the designers
of those outside functions or other programmers to supply public contracts
for them. The correctness of the code on the calling side would then be
contingent upon the correctness of those contracts. An acceptable
compromise.

> This means the system has to be either permissive or conservative when
> encountering an problem insoluble to its logic, and this fall-back
> mechanism will then work counter-intuitively to its normal working
> order, thus giving birth to the system's dualism of both
> conservativeness and permissiveness.

Well, it would still be either one or the other. Not both. Or perhaps I
still don't understand your point.

I do find this topic fascinating.

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list