Inherent code performance advantages of D over C?

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Dec 6 23:15:00 PST 2013


07-Dec-2013 03:55, H. S. Teoh пишет:
> On Fri, Dec 06, 2013 at 03:19:24PM -0800, Walter Bright wrote:
>> On 12/6/2013 3:02 PM, Maxim Fomin wrote:
>>> - phobos snowball - one invocation of some function in standard
>>> library leads to dozens template instantiations and invocations of
>>> pretty much stuff

 > One low-hanging fruit that comes to mind is to use local imports instead
 > of module-wide imports. If the local imports are inside templated
 > functions, I *think* it would prevent pulling in the imports until the
 > function is actually used, which would have the desired effect. (Right?)
 > Much of Phobos was written before we had this feature, but since we have
 > it now, might as well make good use of it.

A major point is to decouple feather-weight "traits" part of modules and 
the API part of module (preferably also split by category).
Then a given Phobos module may do something like this:

import std.regex.traits;

auto dirEntries(C, RegEx)(in C[] path, RegEx re)
	if(isSomeChar!C && isRegexFor!(Regex, C))
{
	import std.regex; //full package
	...
}


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list