Unofficial wish list status.

Xinok xnknet at gmail.com
Sun Dec 31 22:36:40 PST 2006


I'd like to give my thoughts on some of these 'wishes'

-- Inline enum declaration
I think this should be unlocked using a keyword. For example:
void func(decl enum{Show, Hide}sw);
But I like that D doesn't require a semi-colon after an enum declaration.

-- Return Type Overloading
Their design is a bit awkward, and it can be improved a lot IMO. Overloading a
function by it's return type should be no different than overloading the cast
operators in a class.

int func(); short func(); float func();

int a = func();
// In the example, they claim this is ambiguous. The compiler should be smart
enough to go with the closest type 'int'

a = call(int)func();
// A 'call' keyword isn't necessary. Using a typecast would work just fine:
a = cast(int)func();


-- Multiple Return Values
I think the best way to tackle this is with tuples.

- Make a way to declare tuples without the need for declaring a template
- Allow naming tuple arguments.
- Create a simple syntax for returning multiple values

tuple(int a, int b) func(){
// Declare a tuple without the need for a template
// Allow naming tuple arguments
	return 15, 30;
	// Simple syntax for returning multiple values
}

int main(){
	auto ret = func();
	writefln(ret.a + ret.b);

	writefln(func().b);
}


-- array initialization/literals
They gave this design for initalizing associative arrays:
int[char[]] aa = ["one":1, "two":2, "three":3]

This design would be a problem if you used a conditional ? : for the index. My design:
int[char[]] aa = [["one"] = 1, ["two"] = 2, ["three"] = 3];
int[][int] aa = [[0] = [15, 30], [1] = [45, 60, 75]];
int[int][int] aa = [[0][1] = 15, [2][3] = 30]; // This would be nice, though I'm
not sure if it would work


I added two wishes of my own:
- 'Renew' keyword - A keyword for reallocation
http://all-technology.com/eigenpolls/dwishlist/index.php?it=108

- Multi-dimensional Allocation
http://all-technology.com/eigenpolls/dwishlist/index.php?it=109



More information about the Digitalmars-d mailing list