D - Great disappointment!!! (about templates...)
- Achilleas Margaritis (31/31) Apr 19 2004 Dear fellow D programmers,
- =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= (7/15) Apr 19 2004 You are probably looking for this:
- Achilleas Margaritis (3/18) Apr 20 2004 Thanks.
Dear fellow D programmers,
Today I downloaded the D compiler and linker and the DIDE environment. After
playing a little with the example programs and the compiler/DIDE, I decided to
build my own D framework. I started from collections...from a linked list
specifically.
I went on and wrote my first template class:
public template List(T) {
<bla bla constructors destructors etc>
}
...only to find out that D has no template classes!!!
WHAT A GREAT DISAPPOINMENT!!! am I doing something wrong? :-)
A template declaration is not a class, it is just a namespace for including
other declarations inside it.
What I should have done is:
public template List(T) {
class List {
<bla bla list>
}
}
But, in my humble opinion, I think it is not good. When I want to instantiate a
template list class, i have to do the following:
List!(int).List* myList = new List!(int).List;
I consider this way of declaring templates a flaw. Please correct me If I'm
wrong. D was supposed to improve on C++, and indeed it does in many areas, but
why templates have to be so awkward ? Templates and generic programming is
something very important. What was wrong with the way C++ does it ? D's way is
strange, not as readable as C++, it makes the programmer type a lot of things.
Please, put template classes in D. I would like to write:
List(int)* list = new List(int);
and
alias List(int) IntList;
Apr 19 2004
Achilleas Margaritis wrote:
...
public template List(T) {
<bla bla constructors destructors etc>
}
....only to find out that D has no template classes!!!
WHAT A GREAT DISAPPOINMENT!!! am I doing something wrong? :-)
You are probably looking for this:
class List(T)
{
<bla bla constructors destructors etc>
}
List!(int) list = new List!(int);
Apr 19 2004
Thanks. "Julio César Carrascal Urquijo" <adnoctum phreaker.net> wrote in message news:c61hra$1tpb$1 digitaldaemon.com...Achilleas Margaritis wrote:... public template List(T) { <bla bla constructors destructors etc> } ....only to find out that D has no template classes!!! WHAT A GREAT DISAPPOINMENT!!! am I doing something wrong? :-)You are probably looking for this: class List(T) { <bla bla constructors destructors etc> } List!(int) list = new List!(int);
Apr 20 2004








"Achilleas Margaritis" <axilmar in.gr>