Unofficial wish list status.
janderson
askme at me.com
Mon Jan 1 02:52:14 PST 2007
Some good points. See my thoughts on your thoughts below...
Xinok wrote:
<snip>
> -- 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'
What about?
byte func(); short func(); float func();
int a = func();
I think in these cases the compiler should just say its ambiguous and
recommend the user cast to the type they want. ie:
Error: func() overload is ambiguous. Could be byte func() or short
func(). You may indicate which one by use of a cast.
<snip>
> -- 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 don't like this format it way to long so it doesn't save you much, you
might as well do this:
int[char[]] aa; aa["one"] = 1; aa["two"] = 2; aa["three"] = 3;
I don't think conditionals would be to much of a problem, they could be
bracketed:
int[][int] aa = [(X?Y:Z):[15, 30], 1:[45, 60, 75]];
>
>
> I added two wishes of my own:
> - 'Renew' keyword - A keyword for reallocation
> http://all-technology.com/eigenpolls/dwishlist/index.php?it=108
C++ doesn't have a renew because its difficult to work out what would
happen to the objects (would they be recreated -> copied using the copy
constructor?). It would be a good idea to describe how it would work
and all the edge cases.
See:
http://cpptips.hyperformix.com/cpptips/renew.txt
(This is a common interview question "Why is there no renew operation
like C's realloc function in C++?")
I think this case is rare enough in D, that this just becomes bloat. 99%
of the time D's dynamic arrays will be fine, although if we didn't
have D's arrays I'd be all for it.
>
> - Multi-dimensional Allocation
> http://all-technology.com/eigenpolls/dwishlist/index.php?it=109
This is a good idea.
More information about the Digitalmars-d
mailing list