September 18, 2006
Walter Bright wrote:
> Array literals, by popular demand.
> 
> http://www.digitalmars.com/d/changelog.html

You are a god, Walter.  :)  Once the "static initializer" catch bug is fixed, I guess I can deprecate/remove Cashew's array tfunc.  Multidim new is nice as well.

One question though: I assume the answer is yes, but are multidim literals allowed?
[[1, 2, 3], [9, 8, 7]

Assuming literal arrays resolve to variable-length arrays, I'd imagine they would be.

-- Chris Nicholson-Sauls
September 18, 2006
Chris Nicholson-Sauls wrote:
> One question though: I assume the answer is yes, but are multidim literals allowed?
> [[1, 2, 3], [9, 8, 7]

Yes.

> Assuming literal arrays resolve to variable-length arrays, I'd imagine they would be.

They resolve to fixed length arrays, which can be implicitly converted to variable length arrays.
September 18, 2006
Walter Bright wrote:
> clayasaurus wrote:
>> Walter Bright wrote:
>>> Array literals, by popular demand.
>>>
>>> http://www.digitalmars.com/d/changelog.html
>>
>> Why isn't
>>
>> int bob[] = [2,3] allowed but
>>
>> int bob[]; bob = [2,3]
>>
>> is allowed?
> 
> A bug? <g>

Alright, is this feature supposed to work with multi-dimensional arrays as well? like...

bob[][] = [[2,3], [4,2], [2,0]];

I get 'invalid conversion from int[2][3] to int[][]'

Anyways I do like this feature, thanks!

~ Clay
September 18, 2006
clayasaurus wrote:
> Alright, is this feature supposed to work with multi-dimensional arrays as well? like...
> 
> bob[][] = [[2,3], [4,2], [2,0]];
> 
> I get 'invalid conversion from int[2][3] to int[][]'

Since T[n] and T[] are different types, one gets picked. But you can do:

int[][] bob = [ cast(int[])[2,3], [4,2], [2,0] ];

as the element type of the array is determined by the type of the first element.
September 18, 2006
Walter Bright wrote:
> Array literals, by popular demand.
> 
> http://www.digitalmars.com/d/changelog.html

Okay, multidim new is still cool, but I've found that it only works if one uses the parenthetical form.  In other words, this fails to compile:
foo = new int[2][3];

But this works just fine:
foo = new int[][](2, 3);

Not really a show-stopper in my opinion, but certainly lackluster.  (The feature is still awesome to have, though!)

-- Chris Nicholson-Sauls
September 18, 2006
Walter Bright wrote:
> Array literals, by popular demand.
> 
> http://www.digitalmars.com/d/changelog.html

"# Implemented Steward Gordon's suggestions per D.bugs/3843."

And mistyped my name again I see.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
September 18, 2006
Walter Bright wrote:
> Array literals, by popular demand.
> 
> http://www.digitalmars.com/d/changelog.html

Outstanding Walter.  Thank you.

This is certainly going to make some code out there a *lot* less clunky.

-- 
- EricAnderton at yahoo
September 18, 2006
Chris Nicholson-Sauls wrote:
> Walter Bright wrote:
>> Array literals, by popular demand.
>>
>> http://www.digitalmars.com/d/changelog.html
> 
> Okay, multidim new is still cool, but I've found that it only works if one uses the parenthetical form.  In other words, this fails to compile:
> foo = new int[2][3];
> 
> But this works just fine:
> foo = new int[][](2, 3);
> 
> Not really a show-stopper in my opinion, but certainly lackluster.  (The feature is still awesome to have, though!)

The reason it fails to compile is because:

	new int[2][3]

allocates a 3 element array of int[2], not int[]. Static arrays are different types from dynamic arrays.
September 18, 2006
Stewart Gordon wrote:
> Walter Bright wrote:
>> Array literals, by popular demand.
>>
>> http://www.digitalmars.com/d/changelog.html
> 
> "# Implemented Steward Gordon's suggestions per D.bugs/3843."
> 
> And mistyped my name again I see.
> 
> Stewart.

Sorry about that. Fixed.
September 18, 2006
Walter Bright wrote:
> Array literals, by popular demand.
> 
> http://www.digitalmars.com/d/changelog.html

Very nice Walter! Thanks as usual.

I smell one dot oh approaching!

-DavidM