change mixins

retard re at tard.com.invalid
Tue Feb 16 07:19:22 PST 2010


Tue, 16 Feb 2010 00:46:52 +0100, grauzone wrote:

> How about
> 
> class Log
> {
> 	void logInfo(char[] format, ...) {
> 		if (infoEnabled)
> 			std.format.doFormat(&log, _arguments, _argptr);
>    	}
> }
> 
> Log.logInfo("created object %s", obj);
> 
> 
> Doesn't require new features, doesn't require lazy, doesn't require
> thousands of templates, works if Log is an interface.
> 
> Granted, even if logging is disabled, the compiler will push the
> arguments on the stack and call logInfo().

This is a case where a JIT compiler wins. The code runs equally fast 
without the call at all and with logging turned off (dynamically). In 
languages like D, the like has to be statically turned off unless 
compilers have any new dynamic optimizations.



More information about the Digitalmars-d mailing list