October 20, 2001 Some thoughts about D | ||||
---|---|---|---|---|
| ||||
Hi, there are some things I would like to discuss in the language... * Disclaimer: I didn't take my compiler class yet... I'm way less knowledgeable than some of the people in this newsgroup, I apologize if my comments are kinda dumb / unimplementable. * Could bigint, bitgfloat be implemented directly in the language? I would like to be able to work with very large number directly in a basic type, without resorting to using specialized math library to deal with big numbers. Maybe a pointer could be used internally to point to the memory associated to the number, which can grow / shrink as needed. Next think (I know this issue already been posted, but ...), variable arguments in a function. Multiple arguments are sometime a necessity (printf and the like). Saying that they are not used often does not solve the problem for the few functions that need to be implemented that way. Perl deals quite nicely with the problem. The arguments of the function are placed in a single array ( @_ ). You might do the same thing in D, by using an array of pointers. Then each pointer in the array points to one argument. Of course, in that case, you must either allow the cast of each of these pointers, or make sure the programmer is using the type he thinks he is using: void print_int (pointer[] arg) { int num_arg = arg.length; int *ptr; for(int index = 0; index < num_arg; index++) { ptr = arg[index]; // Explicit reference to an int. Check assertion during devel compile mode, // drop it when compiling for normal application use. printf("%d\n", *ptr); } } Support for C malloc() and free()? Getting rid of the need of these are the principal reason I am attracked by D. I'm sick of tracking pointer bugs in my code! But, like Walter wrote, D won't cope well in real-time environnement if it runs a garbage collector at unexpected time (in a separated thread!) for unknown amount of time. It might even break some multimedia apps (games and the like must run when they need to run). Using only malloc() and free() coud bypass entirely the garbage collector when your programming needs command you to. (Even in class through user-defined function that mimics a destructor). I don't entirely understand why you need to need the garbage collector in a separate thread. Doesn't it suffices to 'call' it during memory allocation (new etc) and after you return from a function? That being said, I really think D will be a great language. I believe it has the potential to run at C-like speed. I think it could even be used for kernel programming if one could bypass the garbage collector by using only malloc's and free's and implementing dynamic array and associaltive array with them, while still enjoying the other features D have over C. Good luck for the compiler! |
Copyright © 1999-2021 by the D Language Foundation