What's left for 1.0?

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sat Nov 18 02:30:13 PST 2006


Bill Baxter wrote:
> Bill Baxter wrote:
> 
>> So, what's left on everyone's lists for D1.0 must-have features?
> 
> 
> For a language that has unheard of features like variadic template 
> support (!) one thing that seems oddly immature to me is support for 
> static initializers.  Things like:
> 
> * No way to initialize a static array without counting elements
>     static byte[???] imageData = [...];   // i hope you like counting!

Agreed.  No idea off the top of my head, though, except maybe allowing something like:
# static byte[$] imageData = [...];

> * No way to initialize a dynamic array with a known length
>     byte[] imageData;  imageData.length = 5;  // two steps - meh

# byte[] imageData = new byte[5];
Works right now.

> * No way to initialize array of strings
>     char[][] list = ["eggs","bacon","milk","break"];  //uh uh

There are two ways to do it, right now... but I do still agree they aren't particulary 
elegant.  Way #1:
# char[][] list = [cast(char[]) "eggs", "bacon", "milk"];

Way #2:
# import cashew .utils .array ;
#
# auto list = array!(char[])("eggs", "bacon", "milk");

> * No way to initialize non-static struct
>     Point p = { x:1.0, y:2.0 };  // nope...not static

This has annoyed me as well.  We can get a tuple of a struct now, for goodness sakes; 
surely we can accomplish a simple little initializer!

> * No way to initialize associative array
>     char[int] strTable = {"hello":5, "hi":2, "greetings":9}; // no way

Ditto.  The closest I can offer is Cashew again:
# import cashew .utils .array ;
#
# auto strTable = assoc!(int, char)(
#   [5      , 2   , 9          ],
#   ["hello", "hi", "greetings"]
# );

I made the thing, and yet even I cringe.

> 
> 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

Its the paradox/irony of D, it seems.  Hopefully these things get taken care of in the 
next month or so, before its "too late"!

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list