foreach thoughts

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Tue Jan 14 01:30:49 PST 2014


On Tuesday, 14 January 2014 at 09:06:23 UTC, Jakob Ovrum wrote:
> Regardless of whether binary ! is "ugly" or not, it's still 
> better than introducing language features left and right to 
> avoid templates, and it's still better than C++'s template 
> instantiation syntax :)

C++'s templates are horrible for other reasons! D's 
metaprogramming is much more readable (except for template 
instantiation, of course ;^)

> LDC and GDC are capable of unravelling the (fairly thin) 
> abstraction. All it requires is the ability to inline direct 
> function calls to small functions - the aforementioned 
> compilers always have this capability for templated functions.

But what happens when you chain multiple modifying functions? A 
high level optimizer can have heuristics to transform a complex 
expression into some kind of normal form which the lower level 
have heuristics to deal with.

> DMD is hit and miss, but I think there was a recent improvement 
> to its inliner... luckily this is still the domain of 
> micro-optimization.

Not really! I think you need high level optimization in order to 
have an efficient generic programming environment.

Like, if you want to encapsulate generators. (e.g. if you ask a 
factory for a filtered and sorted list, which returns a 
generator,  then you need more filters, then you send it to 
another function which is generic and applies sort again etc)


More information about the Digitalmars-d mailing list