Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-08 Thread 12345swordy via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:03:47 UTC, aberba wrote: Syntactically they look the same (although D's can do more things) so I'm trying to understand how why in D it's called template but in languages like C#/Java they're generics. I guess I have fair understanding of D's code generation but

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-08-07 23:03, aberba wrote: Syntactically they look the same (although D's can do more things) so I'm trying to understand how why in D it's called template but in languages like C#/Java they're generics. I guess I have fair understanding of D's code generation but isn't it same as wh

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-08-07 23:39, H. S. Teoh wrote: They are *very* different. Java generics are based on "type erasure", i.e., at the syntactic level, containers are parametrized with the element types, but at the implementation level, the element types are merely "erased" and replaced with Object (a top t

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Aug 08, 2020 at 01:47:27AM +, jmh530 via Digitalmars-d-learn wrote: > On Friday, 7 August 2020 at 21:39:44 UTC, H. S. Teoh wrote: > > [snip] > > "Furthermore, it can dispatch to a type-erased implementation ala Java > -- at your choice;" > > This is interesting. Would you just cast to

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread jmh530 via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:39:44 UTC, H. S. Teoh wrote: [snip] "Furthermore, it can dispatch to a type-erased implementation ala Java -- at your choice;" This is interesting. Would you just cast to Object?

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:03:47 UTC, aberba wrote: Syntactically they look the same (although D's can do more things) so I'm trying to understand how why in D it's called template but in languages like C#/Java they're generics. In D, a copy of the function is created for each new template

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 07, 2020 at 09:03:47PM +, aberba via Digitalmars-d-learn wrote: > Syntactically they look the same (although D's can do more things) so > I'm trying to understand how why in D it's called template but in > languages like C#/Java they're generics. > > I guess I have fair understandi

How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread aberba via Digitalmars-d-learn
Syntactically they look the same (although D's can do more things) so I'm trying to understand how why in D it's called template but in languages like C#/Java they're generics. I guess I have fair understanding of D's code generation but isn't it same as what what is available in those langua