www.digitalmars.com         C & C++   DMDScript  

D - random ideas

I wrote a small program in my brain (too bad there's no D there) and made it
pop out random ideas. Well, not really (that'd be cool: a programmable

I know it's been suggested before, but I'd like an automatic declared
variable for every function, so it can be returned. It can be `result´, the
same name as the function, or maybe something like this:

return_type name (type arg0,type arg1,type arg2...) result (var) {

So `var´ becomes of the same type `return_type´. This could be handy if you
have a return type `MyVeryOwnTypeThatIUseQuiteOften´.

Speaking of that, let's say you have 5 arguments of that type MyVery...
Wouldn't it be nice if you could do something like in Delphi:

procedure someProc

The syntax should be different, but the idea remains.


I don't remember well if it has been requested (though I think it was), but
what about having intervals in switch statements. Basic has it, Fortran has
it. Maybe D could have it too. Instead of having:

switch (var) {
    case 0:
    case 1:
    case 2:
    case 560:
    case 562:
    case 564:
    case 565:
    case 566:
    case 998:
    case 999:

(Ok, that's a bit exagerated), you could have:

switch (var) {
    case 0..560,562,564..999:

I think it's better. (By the way, wasn't `default´ mandatory? when did that


I've asked for it before, I'll do it again: D needs some direct way to
resize arrays. Instead of having:

int [][][] myArray;
myArray=new int[x][][];
for (i=0;i<x;i++) {
    myArray[i]=new int[y][];
    for (j=0;j<y;j++)
        myArray[i][j]=new int[z];

(I know you can handle the length property, but still...) There could be
something like in Basic:

redim myArray[x][y][z];

Or in Fortran (I don't know the exact syntax):

allocate (myArray[x][y][z]);

And, if we're talking about an array of some class, maybe it could
automatically call the constructor for each element of the array. Or only if
given or speficied.

Talking about arrays, maybe there could be room for something like this:

int [2..24] a;
int [-12..12][1..9] b;

Delphi has it and VB had it (not anymore in .Net).

Why did nobody say anything about my idea of internal functions (functions
inside function)?


I just hope this suggestions don't seem too... mmm... dumb? newbies? (Don't
comment on this line, please).

Carlos Santander

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 2003-01-27
Feb 05 2003