March 10, 2010
On 10/03/10 11:06, Nick Sabalausky wrote:
> "Philippe Sigaud"<philippe.sigaud@gmail.com>  wrote in message
> news:mailman.119.1268166534.4461.digitalmars-d-announce@puremagic.com...
>>
>> enableStomping?
>>
>
> placeUnderFoot?
>
greekWedding?

March 12, 2010
On 8.3.2010 7:54, Walter Bright wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for
> error messages)
>
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.057.zip
>
>
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.041.zip
>
> Thanks to the many people who contributed to this update!

In 2.040 this worked:

real x = 1.2;

real[4][4] M2 = [
	[1, 0, 0, x],
	[0, 1, 0, x],
	[0, 0, 1, x],
	[0, 0, 0, 1]
];


In 2.041 it has to be written like this:

real x = 1.2;

real[4][4] M2 = [
	[1, 0, 0, x],
	[0, 1, 0, x],
	[0, 0, 1, x],
	[0, 0, 0, cast(real)1]
];

Don't know if the first one should still work and this is a bug or is the new behaviour ok so I am checking here.

The error on the first array initialization in 2.041 is

Error: incompatible types for (([cast(real)1,cast(real)0,cast(real)0,x]) ? ([0,0,0,1])): 'real[]' and 'int[]'
ArraysTest.d(23): Error: cannot implicitly convert expression ([0L,1L,0L,x]) of type real[] to int
ArraysTest.d(23): Error: cannot implicitly convert expression ([0L,0L,1L,x]) of type real[] to int
March 12, 2010
On Fri, 12 Mar 2010 09:14:26 -0500, Ivan <ivan.senji@gmail.com> wrote:

> On 8.3.2010 7:54, Walter Bright wrote:
>> Lots of meat and potatoes here, and a cookie! (spelling checker for
>> error messages)
>>
>> http://www.digitalmars.com/d/1.0/changelog.html
>> http://ftp.digitalmars.com/dmd.1.057.zip
>>
>>
>> http://www.digitalmars.com/d/2.0/changelog.html
>> http://ftp.digitalmars.com/dmd.2.041.zip
>>
>> Thanks to the many people who contributed to this update!
>
> In 2.040 this worked:
>
> real x = 1.2;
>
> real[4][4] M2 = [
> 	[1, 0, 0, x],
> 	[0, 1, 0, x],
> 	[0, 0, 1, x],
> 	[0, 0, 0, 1]
> ];
>
>
> In 2.041 it has to be written like this:
>
> real x = 1.2;
>
> real[4][4] M2 = [
> 	[1, 0, 0, x],
> 	[0, 1, 0, x],
> 	[0, 0, 1, x],
> 	[0, 0, 0, cast(real)1]
> ];
>
> Don't know if the first one should still work and this is a bug or is the new behaviour ok so I am checking here.
>
> The error on the first array initialization in 2.041 is
>
> Error: incompatible types for (([cast(real)1,cast(real)0,cast(real)0,x]) ? ([0,0,0,1])): 'real[]' and 'int[]'
> ArraysTest.d(23): Error: cannot implicitly convert expression ([0L,1L,0L,x]) of type real[] to int
> ArraysTest.d(23): Error: cannot implicitly convert expression ([0L,0L,1L,x]) of type real[] to int

This is a bug.  Any time you are specifying the exact type on the lhs of a literal assignment, the literal should be typed that way.

-Steve
March 12, 2010
> In 2.041 it has to be written like this:
> 
> real x = 1.2;
> 
> real[4][4] M2 = [
> 	[1, 0, 0, x],
> 	[0, 1, 0, x],
> 	[0, 0, 1, x],
> 	[0, 0, 0, cast(real)1]
> ];

I have seen something different, using dmd 2.041 on Windows. Here are few cases of code followed by the error messages dmd outputs to me.

A good way to write code that contains a little less bugs is to try all possible corner cases, systematically, orthogonally, trying all the little boxes you can find in the matrix/tensor of possibilities (like Guy Steele did when he designed Java attributes). I think dmd will need few more tons of tests.

-----------------------

real x = 1.2;
real[4][4] M2 = [[1, 0, 0, x],
                 [0, 1, 0, x],
                 [0, 0, 1, x],
                 [0, 0, 0, cast(real)1]];
void main() {}


test.d(5): Error: non-constant expression x
test.d(5): Error: non-constant expression x
test.d(5): Error: non-constant expression x

-----------------------

real x = 1.2;
real[4][4] M2 = [[1, 0, 0, x],
                 [0, 1, 0, x],
                 [0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}



bug1.d(5): Error: non-constant expression x
bug1.d(5): Error: non-constant expression x
bug1.d(5): Error: non-constant expression x

-----------------------

const real x = 1.2;
real[4][4] M2 = [[1, 0, 0, x],
                 [0, 1, 0, x],
                 [0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


No errors with const, immutable, enum.

-----------------------

const real x = 1.2;
real[4][4] M2 = [[0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


No errors.

-----------------------

const real x = 1.2;
real[4][2] M2 = [[0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


No errors.

-----------------------

const real x = 1.2;
real[2][4] M2 = [[0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


bug1.d(3): Error: cannot implicitly convert expression ([0,0,0,1]) of type int[] to real[2u]

This seems a wrong error message at best.

-----------------------

Can't x be mutable? So are array literals kinda constant now? Do you see something that needs to go to Bugzilla?

Bye,
bearophile
March 13, 2010
Lars T. Kyllingstad wrote:
> It seems array literals have become dynamic arrays, but I can't find any mention of that in the change log.

I'll fix.
March 13, 2010
I have added some of those things to an older bug report: http://d.puremagic.com/issues/show_bug.cgi?id=3948

Bye,
bearophile
1 2 3 4 5 6 7 8
Next ›   Last »