Hi,
for some time now, a Wikipedia page is rumoring that languages
other than C++ and D can be used to achieve the effects of
template *meta*programming. That is, we can have our compilers
compute "functions," recursively, at compile time. The term
"function" here refers to an abstract mathematical thing and
their outcome is (the appearance of) a somewhat different program,
produced implicitly, at compile time.
(A standard example is factorial, showing two essential
characteristics of template metaprogramming, not usually
present in generics:
(1) have the compiler compute factorial(N), N being known at
compile time, by recursively instantiating a series of templates
(at compile time). Each instantiation in turn triggers the
instantiation of more of the same templates (with N decremented)
until finally the compiler finishes its work when it finds
a template specialized for the case N = 0.
(2) No function code is produced, just a result.)
I don't think this recursive template resolution has much to
do with generics in Eiffel, or has it?
Note that this is *not* just about good optimizers: these will
compute factorial(N), too, without anything generic in sight,
when N is known at compile time.
That's beside the point. Eiffel Compilers will still do as
they should and produce code of a feature named "factorial"
should that feature have been defined in a class. The C++
example leaves no function.
Also, can Eiffel generics be used for turning dynamic polymorphism
into static polymorphism?
I'll boldly correct the Wikipedia article should the above
negative result be correct.
- Georg