On Mon, 10 Oct 2016, Wouter van Ooijen wrote: > Op 10-Oct-16 om 2:45 PM schreef smplx: >> >> On Mon, 10 Oct 2016, Wouter van Ooijen wrote: >> >>> In your idea, as a user, can I be *sure* that a certain (complicated) >>> part is run by the compiler at compilation? >>> >>> In C++ 0x14 you can >>> >>> - declare any function as constexper, which means that the compiler mus= t >>> check that it can evaluate that function at compile time (provided that >>> it knows the arguments at compile time). Such a function is still usabl= e >>> at run time too. >>> >>> - declare any const value as constexpr, which means that the compiler >>> must evaluate it at compile time. >>> >>> There isn't much special about a constexpr function that isn't obvious >>> (like: it can't access globals, can't do memory allocation, etc.). >> Hi Wouter, >> >> The short answer is yes - if you declare a constant and use a function t= o >> initalise it that does not depend on external unknowns. >> >> The longer answer is "it is not intended to be restricted that way". Whe= n >> I explained how functions could be executed at compile time this was an >> attempt to quickly focus the reader on an obvious benefit. The reallity >> however is that compile time execution goes way beyond what I described. >> It opens up a huge number of possibilites for deep analysis and >> optimisation which I have not described. It is not just about executing >> functions as a unit but about executing as much of the code as possible >> without the function call acting as a barrier. >> >> What I would like to see users doing is writing code that describes the >> process they need to achive and let the compiler worry about the >> optimisation. > > IMO that sounds good, but it is what an optimizer should do anyway. On > top of that, you (as an application writer) want guarantees that certain > parts are pre-caclulated. That is not worrying, that is getting certainty= .. > Hi Wouter, If you are saying that you want to be able to guarantee that calling a=20 function at a given place in your code will always cause the compiler to=20 execute it at compile time then yes I could easily add a keyword (or some=20 other simple mechanism) that will do that. It would not be hard at all. e.g. int x =3D (execute now)fred(); I guess I could even add an attribute to the function itself so that it=20 only ever gets executed by the compiler, that would not be hard either. Regards Sergio Masci --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .