March 06, 2006
> From what I read, C# generics do not instantiate a new routine for every set of argument types, it implements *one* routine which handles them all via casting.

Yep.

And more here:
Templates and Generics
http://blogs.msdn.com/branbray/archive/2003/11/19/51023.aspx


March 07, 2006
Don Clugston wrote:

> Clearly C# does it a lot better than Java does. Java generics seem to be 100% syntactic sugar.

Don't forget that a dynamic compiler can do anything at runtime if the byte-code carries forward enough info about the original source -- class files are extensible. I have seen anonymous local classes reduced to simple functions. With decent escape analysis, allocation on the stack is possible for small value classes. Research on this topic, IMHO, has only scratched the surface.

March 08, 2006
In article <dufcpn$p1n$2@digitaldaemon.com>, Walter Bright says...
>
>
>Technically, Java and C# implement generics, not templates. C++ and D implement templates, not generics.
>
>What's the difference? One way to think about it is generics are handled at run time (by casting), templates at compile time.

sorry "generics" is a generic term, let's let not pigeon-hole it, Ada uses the term and it is compile time

the term "template" was originally associated with patterns,

"In computer science, generics is a technique that allows one value to take different datatypes (so-called polymorphism) as long as certain contracts such as subtypes and signature are kept. The programming style emphasizing use of this technique is called generic programming." en.wikipedia.org/wiki/Template_(programming)

"A generic term is one which picks out a class of individuals, or the prototype of the individual, rather than the individual itself. For example, in the sentence `The wolf has disappeared from northern Europe,' we are referring to the genus rather than to a particular wolf." www.informatics.susx.ac.uk/books/computers-and-thought/gloss/node1.html


March 09, 2006
Mark T wrote:
> 
> [T]he term "template" was originally associated with patterns,
> 
> "In computer science, generics is a technique that allows one value
> to take different datatypes (so-called polymorphism) as long as
> certain contracts such as subtypes and signature are kept. The
> programming style emphasizing use of this technique is called generic
> programming." en.wikipedia.org/wiki/Template_(programming) [...]"
...
> www.informatics.susx.ac.uk/books/computers-and-thought/gloss/node1.html

Put like that, it becomes obvious how much of the generic stuff can be done with Interfaces.

Even with the STL, all the stuff that trickles through "my custom made procedures and functions" needs certain properties. C++ did a good job of integrating the fundamental data types and structures to this.

With anything that's objects, D can already be very powerful when one combines well factored interfaces with a solid set of orthogonal (not necessarily member-) functions.

I love D!
1 2 3
Next ›   Last »