Is there a term for a type of program that is guaranteed to always produce the same output? For example, it never accepts keyboard input, never reads a timer, etc, so it must always follow the same execution path.
The only term that comes to mind is "deterministic" but that's not quite right.
>>8,9
Well, the running time is pretty much just the number of instructions multiplied by the average time for each instruction. So you could just forego any calculation for that and output a constant.
Overall, a slightly pointless 'what if'.
>>3
Funny you should say that... My motivation for asking was thinking about writing a compiler that let you declare certain sections of your code as "idempotent" (now that I know the term) and having it actually execute these sections of code at build time.
Name:
Darkr2011-01-10 18:32
It's called purity. A pure function is one which will always produce the same output given a particular input. Any function which isn't pure is said to have side effects. Purely functional languages such as Haskell try to be as pure as possible. It's obviously not possible for everything, but the idea is to limit the side effects to only where it's necessary.
>>22
This is inaccurate -- in addition to having no side effects, a pure function must also not depend on external state or be non-deterministic. Thus being impure is not sufficient to have side effects.