"in" everywhere

Simen kjaeraas simen.kjaras at gmail.com
Thu Oct 7 16:49:58 PDT 2010


Tomek Sowiński <just at ask.me> wrote:

> Simen kjaeraas napisał:
>
>> Tomek Sowiński <just at ask.me> wrote:
>>> Even if the attribute properties could see the arguments, how to deal
>>> with things like
>>> lhs.length + rhs.length? It has to be inspectable at compile-time. One
>>> idea is to store the
>>> expression's abstract syntax tree (we want AST macros in D3 anyway)...
>>> But I got a feeling
>>> we're heading for an overkill :)
>>
>> Just as soon as we solve the halting problem, eh?
>
> What's the halting problem?

http://en.wikipedia.org/wiki/Halting_problem

Basically, inspecting the AST in search of the complexity might have an
infinite (or at least, arbitrarily high) complexity itself. It is likely
possible in some situations, but in the general case, not so much.

Also, consider the while loop. It may have an arbitrarily complex
termination condition, making it hard or impossible to find the
complexity. Example, with added complexity by omitting the source of
foo:

extern bool foo( );

void bar( bool delegate( ) dg ) {
     while ( 1 ) {
         if ( dg( ) ) {
             break;
         }
     }
}

bar( &foo );

-- 
Simen


More information about the Digitalmars-d mailing list