What's left for 1.0?
Bill Baxter
dnewsgroup at billbaxter.com
Fri Nov 17 23:21:23 PST 2006
Walter Bright wrote:
> C can't do any of those things.
Sure it can.
>> * No way to initialize a static array without counting elements
>> static byte[???] imageData = [...]; // i hope you like counting!
C has no problem with this. I do it all the time:
static const unsigned char[] = { 1,2,3,4,5,6,7, 255 };
>> * No way to initialize a dynamic array with a known length
>> byte[] imageData; imageData.length = 5; // two steps - meh
C has no problem with this (using malloc, its own concept of "dynamic
arrays"):
byte* imageData = (byte*)malloc(5*sizeof(byte));
A better comparison is C++, which has no problem with it's std library
vector class:
vector<int> imageData(5);
>> * No way to initialize array of strings
>> char[][] list = ["eggs","bacon","milk","break"]; //uh uh
C can do this:
char *list[] = { "eggs","bacon","milk","break" };
>> * No way to initialize non-static struct
>> Point p = { x:1.0, y:2.0 }; // nope...not static
C has no problem with that either:
struct Point { float x, y; };
void foo() {
Point p = {1.0,2.0};
}
(and C99 can do it with the x: y: syntax too, I think)
>>
>> * No way to initialize associative array
>> char[int] strTable = {"hello":5, "hi":2, "greetings":9}; // no way
Well you got me there. C can't do that.
>> I know things have gotten much better since the old days, when there
>> weren't even array literals (yikes!), but it still looks pretty
>> primitive in some ways compared to C.
--bb
More information about the Digitalmars-d
mailing list