Walter Bright wrote:
BLS wrote:
The current Template specialization implementation is doing a best fit
search anyway, so why constraints are not able to use the same
mechanism. ?
The template specialization method is based on types - but there's no
way to look inside those types and specialize based on properties of
those types. That's where constraints come in.
Constraints use a completely different matching method than the type
parameters do. It makes intuitive sense to logically separate them,
rather than to mix them up.
Thanks for taking the time to answer ; But the question remains the same
: _Why_ ? Constraints /have/ to use a completely different approach ?
("more intuitive than" is not ..ahem.. is not a good enough reason)
bearophile brings in several times Scala/OCAML like pattern matching.
Why not using that for constraints ?
I have no idea how that works, though Bartosz has been looking into it.
O well, I am pretty sure that bearophile is willing to give you any
information you need :)