I just wanted to share how all the perceived confusion about static
typing being a bad thing is usually trumped by a compiler feature in
C++ called argument type deduction. Although this still happens during
compile time (as opposed to runtime with other languages), it
shouldn't make much difference because in runtime languages you do
have to instigate a recompile albeit automatically when then source
changes.
An example would be creating free functions that adhered by an
interface instead of a type like:
template <typename T>
void swap(T & left, T & right);
When using these functions though, you don't have to explicitly fill
in the template parameters: instead have the compiler do it for you:
int a = 1, b = 2;
double c = 1.0, d = 2.0;
float e = 1.0f, f = 2.0f
swap(a, b);
swap(c, d);
swap(e, f);
This technique allows for writing generic and type-safe algorithms and
solutions.
I hope you'll find it useful someday! :)
--
Dean Michael C. Berris
C++ Software Architect
Orange and Bronze Software Labs, Ltd. Co.
web: http://software.orangeandbronze.com/
email: de...@orangeandbronze.com
mobile: +63 928 7291459
phone: +63 2 8943415
other: +1 408 4049532
blogs: http://mikhailberis.blogspot.com http://3w-agility.blogspot.com
http://cplusplus-soup.blogspot.com
~ Scott
don't forget concepts! c++ is waaayyy ahead from the rest.
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
I personally like decltype + auto. Makes for very good fun:
template <typename T1, typename T2>
auto add(T1 const & left, T2 const & right) -> result_of<T1, T2>::type {
};
Or something like that. :)
Indeed. :) I hope to write more axioms than abstract types in the future too.