toHash => pure, nothrow, const, @safe

deadalnix deadalnix at gmail.com
Tue Mar 13 08:47:51 PDT 2012


Le 13/03/2012 15:46, Andrei Alexandrescu a écrit :
> On 3/13/12 6:02 AM, Peter Alexander wrote:
>> On Monday, 12 March 2012 at 09:40:15 UTC, Walter Bright wrote:
>>> On 3/12/2012 1:08 AM, Martin Nowak wrote:
>>>> What's wrong with auto-inference. Inferred attributes are only
>>>> strengthening
>>>> guarantees.
>>>
>>> Auto-inference is currently done for lambdas and template functions -
>>> why? - because the function's implementation is guaranteed to be
>>> visible to the compiler. For other functions, not so, and so the
>>> attributes must be part of the function signature.
>>
>> Dumb question:
>>
>> Why not auto-infer when the function body is available, and put the
>> inferred attributes into the automatically generated .di file?
>>
>> Apologies if I've missed something completely obvious.
>
> Because in the general case functions call one another so there's no way
> to figure which to look at first.
>
> Andrei

This problem is pretty close to garbage collection. Let's use pure as 
example, but it work with other qualifier too.

function are marked pure, impure, or pure given all function called are 
pure (possibly pure). Then you go throw all possibly pure function and 
if it call an impure function, they mark it impure. When you don't mark 
any function as impure on a loop, you can mark all remaining possibly 
pure functions as pure.


More information about the Digitalmars-d mailing list