I just got it! (invariant/const)

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Apr 10 02:23:58 PDT 2008


Lionello Lunesu wrote:
> 
> "Janice Caron" <caron800 at googlemail.com> wrote in message 
> news:mailman.375.1207810102.2351.digitalmars-d at puremagic.com...
>> On 10/04/2008, Lionello Lunesu <lionello at lunesu.remove.com> wrote:
>>>  Why? If pure-ness (uh, purity?) can be checked, it can also be deducted
>>
>> "purity" is the right word. (But "deducted" should be "deduced" :-))
> 
> :-) thanks.
> 
>>> (*), so the compiler could optimize/complain in either case.
>>
>> It would slow down compilation no end though. For example, a pure
>> function is not allowed to call non-pure functions. Without the "pure"
>> keyword, you'd have to follow through every function call recursively,
>> and that could take a long time.
> 
> Yeah, but you'll have to visit those functions anyway, because you're 
> compiling. Granted, header files should explicitely mention 
> pure/notpure, and to make it safe, it must be mangled.

Visited? Yes.
Look at their body? Not if they're in a different module, AFAICT.
If the function is in another module then the declaration should be 
enough (the fact that .di "headers" work confirms this), and the body 
can effectively be ignored beyond checking syntactical correctness (i.e. 
checking that it *could* be valid code provided all identifiers it uses 
resolve to stuff of appropriate types, but not actually looking up any 
of the identifiers mentioned in it).



More information about the Digitalmars-d mailing list