Returning int instead of bool can actually make things _less_ efficient

Karen Lanrap karen at digitaldaemon.com
Thu Dec 7 21:36:35 PST 2006


Stewart Gordon wrote:

> For example, of these, which is more efficient? 

This cannot be answered in general, because at least the features of 
the CPU and the code context play a major role.

In fact Walters main argument for not having bool was an adaption to 
the _current_ behaviour of CPU producers whereas your argument seems 
right that a more precise abstraction may gain efficiency benefits.

To actually have this benefits I do not see any other way than to 
implicitely follow the success of bytecode/VM implementations by 
deferring such decisions to the time of installation.

Such deferring may also provide benefits on a larger scale: for 
example when a CPU outperforms its competitors for a specific task, a 
set of implementations of algorithms may also outperform another such 
set, especially if CPU can flag their capabilities.  

However, Moore's Law may render such expensive structuring useless 
within a close time horizon.




More information about the Digitalmars-d mailing list