Can you imagine C++ templates without template parameter deduction?
What's the alternative: spelling out all the parameter values, wherever the template is used?
mult<int, double>(x, add<double, double>(y, z));
C++ templates use type information to deduce parameters. Lisp macros may be expanded before any type analysis takes place.
The fact that you can just write:
mult(x, add(y, z))
and the language figures out the parameters for the mult and add templates from the declared types of x, y and z doesn't really have any parallel in mainstream Lisp dialects.
The idiomatic solution would involve making the functions themselves generic so they dispatch on the actual types of the arguments.
Anything relying on declared or inferred type would be a second-class citizen in a dynamic language anyway, where declarations are optional, and inference may be imperfect or absent.
What's the alternative: spelling out all the parameter values, wherever the template is used?
C++ templates use type information to deduce parameters. Lisp macros may be expanded before any type analysis takes place.The fact that you can just write:
and the language figures out the parameters for the mult and add templates from the declared types of x, y and z doesn't really have any parallel in mainstream Lisp dialects.The idiomatic solution would involve making the functions themselves generic so they dispatch on the actual types of the arguments.
Anything relying on declared or inferred type would be a second-class citizen in a dynamic language anyway, where declarations are optional, and inference may be imperfect or absent.