This is a mess - was Re: Const sucks
Myron Alexander
someone at somewhere.com
Tue Sep 11 08:14:16 PDT 2007
This is a mess!
The examples given do not indicate how references will be taken care of
nor do they indicate how to deal with templated functions/methods that
change behaviour based on type.
In this method, I want to make toValue final (like Java) if it is a
reference, and const if it is a primitive/structure, how do I do that?
void doSomthing(T) (*declare final* T toValue) {
*whole bunch of common code*
static if (is(T : someobject)) {
work with someobject
}
static if (is(T == int)) {
work with int
}
static if (is(T == char[])) {
work with char[]
}
...
*whole bunch of other common code*
}
In D, there are five main type classes:
1. Primitives (including pointers)
2. Structs - value type
3. Classes - reference semantics
4. Arrays - reference semantics
5. Delegates/Function pointers
Until constness can deal with all types simply (and elegantly), then it
should not be introduced. This way leads to C++ and the kitchen sink
approach. Java does well because it is not a kitchen sink.
Please demote D2.0 from the front-page and revert back to D1.0 so that
new people are not confused with experimental versions.
Regards,
Myron.
More information about the Digitalmars-d
mailing list