On 03/13/2012 11:39 PM, kennytm wrote:
Andrei Alexandrescu<[email protected]>  wrote:
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

That's no difference from template functions calling each others right?

     int a()(int x) { return x==0?1:b(x-1); }
     int b()(int x) { return x==0?1:a(x-1); }

http://d.puremagic.com/issues/show_bug.cgi?id=7205

The non-trivial issue is what to do with compile-time reflection in the function body. I think during reflection, the function should appear non-annotated to itself and all functions with inferred attributes it calls transitively through other functions with inferred attributes regardless of whether or not they are later inferred. (currently inference fails spectacularly for anything inside a typeof expression anyway, therefore it is not yet that much of an issue.)

pragma(msg, typeof({writeln("hello world");})); // "void function() pure @safe"

Reply via email to