|
![](/i/fill.gif) |
Invisible <voi### [at] dev null> wrote:
> Of course, the main one is that it's a 100% functional language
I thought that a 100% functional language has no mutable data structures
nor functions with side-effects.
> C++ has templates, and people often compare this to generics. I'm not
> sure why. As far as I can tell, templates not even remotely similar to
> generics.
Yeah, templates are a lot more powerful and versatile.
> - Templates are, as best as I can tell, preprocessor macros on steriods.
> They automate the process of creating a new, seperate, class for each
> combination of parameter values. It's like copy & pasting each time you
> want a new container class, except the template preprocessor automates
> it for you. This is clearly very much more maintainable, but not the
> same as extending the type checker.
Templates are not used only to generate classes, but also functions and
basic types. Template parameters can also be of almost any type (classes,
basic types, other templates, etc.) Also, templates can be recursive, which
is rather huge.
In short, templates allow compile-time polymorphism (as opposed to runtime
polymorphism in most OO and functional languages).
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |