www.digitalmars.com         C & C++   DMDScript  

D - DMD 0.54 release

reply "Walter" <walter digitalmars.com> writes:
Some long overdue syntax changes. Will break some existing code, but it's
easy to fix.

www.digitalmars.com/d/changelog.html
Feb 15 2003
next sibling parent reply "Jeroen van Bemmel" <anonymous somewhere.com> writes:
"Walter" <walter digitalmars.com> wrote in message
news:b2l2oh$1o27$1 digitaldaemon.com...
 Some long overdue syntax changes. Will break some existing code, but it's
 easy to fix.

 www.digitalmars.com/d/changelog.html
a.. Reversed order of array declarations when they appear to the left of the identifier being declared. Postfix array declaration syntax remains the same (and equivalent to C). int[3][4] a; // a is 4 arrays of 3 arrays of ints int b[4][3]; // b is 4 arrays of 3 arrays of ints I did a quick search on earlier postings on this topic, but found none. In my humble opinion this feature confuses more than it resolves. I would suggest to choose one (I prefer the first)
Feb 15 2003
next sibling parent Ilya Minkov <midiclub 8ung.at> writes:
Jeroen van Bemmel wrote:
 "Walter" <walter digitalmars.com> wrote in message
 news:b2l2oh$1o27$1 digitaldaemon.com...
 
Some long overdue syntax changes. Will break some existing code, but it's
easy to fix.
Thanks!!!!! Now you can tell the novices to use... real and int. But OTOH real,... then i'd expect imaginary and complex, but get ireal and creal. at least it's consistent with integer naming though. but having both float and real in one language is confusing. why not single instead of float? single<=double<=real. :) or sreal, dreal, real? then isreal, idreal, ireal, csreal, cdreal, creal :) no, obfucadion.
 
 a.. Reversed order of array declarations when they appear to the left of the
 identifier being declared. Postfix array declaration syntax remains the same
 (and equivalent to C).
 	int[3][4] a;	// a is 4 arrays of 3 arrays of ints
 	int b[4][3];	// b is 4 arrays of 3 arrays of ints
 I did a quick search on earlier postings on this topic, but found none. In
 my humble opinion this feature confuses more than it resolves. I would
 suggest to choose one (I prefer the first)
 
There's a slight problem. after you've declared: int [x][y] array; //natural order! like in math and most libraries. you still have to acess it this way: el = array[y][x]; //stoopid C order! which becomes once more confusing. especially for people changing from Wirth languages or Sather or anything else more sane than C. Even in C, it has been a source of confusion. I quote from some matrix handling tutorial for beginning 3D enthusiasts: " If something goes wrong try: - reversing the matrix multiplication order - transposing the final matrix - you can't imagine how often this helps! " The first one refers to some people who don't know math :) but the second is a sign of technical problem, since OpenGL and DirectX expect matrices in an oppsite order compared to that usual in C, because of these swapped dimensions! access like: el = array[x,y] would really be good. And with that, also declarations in the same style. How about a possibility for multi-dimensional dynamic continuous arrays? Then array structure would be the following: 0: pointer to array data; 4: 1st array dimension; 8: 2nd array dimension; 12: 3st array dimension; ... ... 4*n: nth array dimension. -i.
Feb 15 2003
prev sibling next sibling parent "Peter Hercek" <vvp no.post.spam.sk> writes:
"Jeroen van Bemmel" <anonymous somewhere.com> wrote in message
news:b2ldol$20m9$1 digitaldaemon.com...
 [cut]
 int[3][4] a; // a is 4 arrays of 3 arrays of ints
 int b[4][3]; // b is 4 arrays of 3 arrays of ints
 I did a quick search on earlier postings on this topic, but found none. In
 my humble opinion this feature confuses more than it resolves. I would
 suggest to choose one (I prefer the first)
I think too that there should be only one way how to define array. I prefer the first one too. One way how to do it should be a rule for everything at the language level. Certainly at the higher levels you have (and should have) a lot of options. My reasoning is again the same: searching and easier writting of higher level tools (smart editors etc).
Feb 15 2003
prev sibling next sibling parent Burton Radons <loth users.sourceforge.net> writes:
Jeroen van Bemmel wrote:
 "Walter" <walter digitalmars.com> wrote in message
 news:b2l2oh$1o27$1 digitaldaemon.com...
 
Some long overdue syntax changes. Will break some existing code, but it's
easy to fix.

www.digitalmars.com/d/changelog.html
a.. Reversed order of array declarations when they appear to the left of the identifier being declared. Postfix array declaration syntax remains the same (and equivalent to C). int[3][4] a; // a is 4 arrays of 3 arrays of ints int b[4][3]; // b is 4 arrays of 3 arrays of ints I did a quick search on earlier postings on this topic, but found none. In my humble opinion this feature confuses more than it resolves. I would suggest to choose one (I prefer the first)
The "C-style array declarations" thread; I lobbied for the swap in array order privately, and also lobbied for removing the C-style; won the former, lost the latter. Walter's position is that this is a necessary fig leaf to C programmers.
Feb 15 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Jeroen van Bemmel" <anonymous somewhere.com> wrote in message
news:b2ldol$20m9$1 digitaldaemon.com...
 a.. Reversed order of array declarations when they appear to the left of
the
 identifier being declared. Postfix array declaration syntax remains the
same
 (and equivalent to C).
 int[3][4] a; // a is 4 arrays of 3 arrays of ints
 int b[4][3]; // b is 4 arrays of 3 arrays of ints
 I did a quick search on earlier postings on this topic, but found none. In
 my humble opinion this feature confuses more than it resolves. I would
 suggest to choose one (I prefer the first)
While the spec necessarilly goes into both syntaxes, you can choose to stick with the prefix notation which is consistent and easy to explain. The C version is there to make an easier migration path for C programmers, etc., and the mixed declarations fall out of that syntax, but can be entirely avoided, and I suggest that they be avoided.
Feb 15 2003
prev sibling next sibling parent Burton Radons <loth users.sourceforge.net> writes:
int [char []] ext;

void main ()
{
    ext ["foo"] = 1;
    delete ext;
}

This compiles, and is proper of course, but fails on execution with an 
Access Violation.
Feb 15 2003
prev sibling next sibling parent reply Burton Radons <loth users.sourceforge.net> writes:
"new" should be changed:

    char [] [] foo;

    foo = new char [] [45]; /* Doesn't work. */
    foo = new char [45] []; /* Old order does work, but no longer makes 
sense. */
Feb 15 2003
parent "Walter" <walter digitalmars.com> writes:
I overlooked that. Thanks. -Walter

"Burton Radons" <loth users.sourceforge.net> wrote in message
news:b2mnbr$2mt$1 digitaldaemon.com...
 "new" should be changed:

     char [] [] foo;

     foo = new char [] [45]; /* Doesn't work. */
     foo = new char [45] []; /* Old order does work, but no longer makes
 sense. */
Feb 15 2003
prev sibling next sibling parent "Mike Wynn" <mike.wynn l8night.co.uk> writes:
found one internal error and one seggy (all due to crap code)
Digital Mars D Compiler Beta v0.54
dmd -c with .....

alias bit delegate ( int ) MyFoo;
class wrong
{
 MyFoo foo;
 bit func( int a )
 {
  return MyFoo( a );
 }
}

causes
bit delegate(int)
Internal error: e2ir.c 1870

and

int a = [ 6, 7, 9 };

crashes the compiler


"Walter" <walter digitalmars.com> wrote in message
news:b2l2oh$1o27$1 digitaldaemon.com...
 Some long overdue syntax changes. Will break some existing code, but it's
 easy to fix.

 www.digitalmars.com/d/changelog.html
Feb 15 2003
prev sibling next sibling parent "Mike Wynn" <mike.wynn l8night.co.uk> writes:
and another bug ...

delegates don't take into account out params.

the following compiles but crashes (as you would expect)
int delegate( out int ) can be passed as int delegate( int ).

alias int delegate( int foo ) MyCB;
class CBHolder {
 MyCB cb;
 this( MyCB cb0 ) { cb = cb0; }
 int evoke( out int foo ) { return cb( foo ); }
}

class Test {
 int a,b;
 this() {
  CBHolder h = new CBHolder( &this.func );
  a = h.evoke( b );
 }

 int func( out int foo ) {
  foo = 9; return 3;
 }
}

int main( char[][] args )
{
 printf("begin\n");
 Test t = new Test();
 printf("test a:%d b:%d\n", t.a, t.b );
 return 0;
}


"Walter" <walter digitalmars.com> wrote in message
news:b2l2oh$1o27$1 digitaldaemon.com...
 Some long overdue syntax changes. Will break some existing code, but it's
 easy to fix.

 www.digitalmars.com/d/changelog.html
Feb 15 2003
prev sibling next sibling parent reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
Duplicate cases not spotted (should they be ?)



char[] func( int a )
{
 switch( a )
 {
 case 0: return "None";
 case 1: return "One";
 case 0: return "None0";
 default: return "-err-";
 }
}

int main( char[][] args )
{
 for( int i = 0; i < 3; i++ )
 {
  printf('i:%d "%.*s"'\n, i, func(i) );
 }
 return 0;
}


"Walter" <walter digitalmars.com> wrote in message
news:b2l2oh$1o27$1 digitaldaemon.com...
 Some long overdue syntax changes. Will break some existing code, but it's
 easy to fix.

 www.digitalmars.com/d/changelog.html
Feb 16 2003
parent "Walter" <walter digitalmars.com> writes:
"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message
news:b2ondj$200b$1 digitaldaemon.com...
 Duplicate cases not spotted (should they be ?)
Yes, they should be. It's a bug. -Walter
Feb 16 2003
prev sibling next sibling parent reply Patrick Down <pat codemoon.com> writes:
The following causes the compiler to blow up with a
null pointer reference.

void foo()
{
  struct Test
  {
    int i;

    bit bar(int a)
    {
      i = a;
    }
  }
  
  Test t;
}

int main(char[][] argv)
{
  
  return 0;
}
Feb 18 2003
parent "Walter" <walter digitalmars.com> writes:
This is a more general bug in that structs/classes local to a function
currently cannot have member functions. It's a compiler bug. -Walter
Feb 19 2003
prev sibling parent reply Dan L. <Dan_member pathlink.com> writes:
Did something happen to local 2d arrays?  I try to compile:

int main (char argv[][], int argc) {
int[3][4] a;
return 0;
}

and I get "cannot implicitly convert int to int[3]".

Dan L.

In article <b2l2oh$1o27$1 digitaldaemon.com>, Walter says...
Some long overdue syntax changes. Will break some existing code, but it's
easy to fix.

www.digitalmars.com/d/changelog.html
Feb 19 2003
parent reply "Walter" <walter digitalmars.com> writes:
Fixed. -Walter
Feb 19 2003
parent Dan L. <Dan_member pathlink.com> writes:
Forgot to mention: the error message gave no file or line number.

Dan

In article <b30sse$kp3$1 digitaldaemon.com>, Walter says...
Fixed. -Walter
Feb 19 2003