Contracts for interfaces and abstract classes

2012-08-19 Thread Mike L.
I'm on ubuntu x64 using dmd 2.060 and the following gives an exception: rdmd --main -unittest -version=useInterface mml/sets.d while the following runs just fine: rdmd --main -unittest -version=useAbstractClass mml/sets.d The exception is: object.Exception@src/object_.d(108): need opCmp for

Unexpected OPTLINK termination

2012-08-19 Thread cal
I just ran into (I think) this bug http://d.puremagic.com/issues/show_bug.cgi?id=8377 using dmd 2.060. Seeing that there was a fix in git, I cloned the latest git dmd, built, and dropped the .exe into my existing dmd 2.060 installation directory. I still get this unexpected optlink terminatio

Re: math.pow fails at compile-time; is this a bug?

2012-08-19 Thread Jonathan M Davis
On Sunday, August 19, 2012 23:38:01 Caligo wrote: > template T(){ > enum a = pow(3.0, 2); > enum b = pow(3, 2.0); > } > > unittest > { > alias T!() t; > } > > compiling that I get: > > /home/b/phobos/std/math.d(2369): Error: Cannot convert &real to ushort* at > compile time > /home/b/phobo

math.pow fails at compile-time; is this a bug?

2012-08-19 Thread Caligo
template T(){ enum a = pow(3.0, 2); enum b = pow(3, 2.0); } unittest { alias T!() t; } compiling that I get: /home/b/phobos/std/math.d(2369): Error: Cannot convert &real to ushort* at compile time /home/b/phobos/std/math.d(3292):called from here: isNaN(y) /home/b/phobos/std/math.d(

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread Era Scarecrow
On Monday, 20 August 2012 at 01:29:06 UTC, maarten van damme wrote: Depends. Do you plan on doing more than brute force? Having it bulk copy them may not be that bad if it's all in one place, and if you do it like that you have all the combinations that carry forward to the next level and if yo

Re: -noboundscheck

2012-08-19 Thread Nvirjskly
On Monday, 20 August 2012 at 02:28:25 UTC, Nvirjskly wrote: Really? that was quick. I didn't get very far with my attempt. =P Ok, committing a broken version. Broken in the sense that it does not work correctly as of yet. *Something* is not working properly. I work on finding out what ex

Re: -noboundscheck

2012-08-19 Thread Nvirjskly
Really? that was quick. I didn't get very far with my attempt. =P Ok, committing a broken version. Broken in the sense that it does not work correctly as of yet. *Something* is not working properly. I work on finding out what exactly some more today and tommorrow, but it is in a "usable"

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
> Depends. Do you plan on doing more than brute force? Having it > bulk copy them may not be that bad if it's all in one place, and > if you do it like that you have all the combinations that carry > forward to the next level and if you back out it undoes them all > automatically. > No, I think

Re: where is parameterNames?

2012-08-19 Thread Ellery Newcomer
On 08/15/2012 09:46 AM, David Nadlinger wrote: Related: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L510 David That should work nicely. Why does it not show up on dlang.org?

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread Era Scarecrow
On Monday, 20 August 2012 at 00:13:41 UTC, maarten van damme wrote: I'm using a static array. Good good.. I'm hesitating though if I should store possibilities in a precalculated array or calculate them in-place. If I precalculate the possibilities I'd have to copy them over and over so I

Re: -noboundscheck

2012-08-19 Thread 1100110
On Sun, 19 Aug 2012 19:26:34 -0500, Nvirjskly wrote: On Sunday, 19 August 2012 at 23:48:36 UTC, 1100110 wrote: Here are my results! iirc -release implies -noboundscheck.. Also I am on x64, and these files only compile to 32bit. So there could be performance missing there. Wow, thanks. It

Re: -noboundscheck

2012-08-19 Thread bearophile
I can't understand what command line arguments you are using for LDC and GDC, but both of them have many useful optimization arguments (some of them are not easy to use like link time optimization in LDC). Bye, bearophile

Re: -noboundscheck

2012-08-19 Thread Nvirjskly
On Sunday, 19 August 2012 at 23:48:36 UTC, 1100110 wrote: Here are my results! iirc -release implies -noboundscheck.. Also I am on x64, and these files only compile to 32bit. So there could be performance missing there. Wow, thanks. It looks like ldc2 does not play nice with std.bigint, whi

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
I'm using a static array. I'm hesitating though if I should store possibilities in a precalculated array or calculate them in-place. If i precalculate the possibilities i'd have to copy them over and over so i don't know if it's smart. Going even further I could even store a filled-in value as an

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread Era Scarecrow
On Sunday, 19 August 2012 at 21:24:26 UTC, maarten van damme wrote: The infinite loop was my mistake. I was looking at your outer while loop but because you use exceptions instead of return values it indeed throws an exception, my bad :) I have a revised version that only does 2 calls for the

Re: stdlib.exit()

2012-08-19 Thread Minas Mina
On Sunday, 19 August 2012 at 23:48:01 UTC, Minas Mina wrote: That's what I do: import std.c.stdlib; void main(string[] args) { if( args.length == 1 ) { writeln("Some arguments, please!"); exit(-1); } } Sorry, forgot to import std.stdio.

Re: stdlib.exit()

2012-08-19 Thread Minas Mina
That's what I do: import std.c.stdlib; void main(string[] args) { if( args.length == 1 ) { writeln("Some arguments, please!"); exit(-1); } }

Re: -noboundscheck

2012-08-19 Thread 1100110
Here are my results!  iirc -release implies -noboundscheck..Also I am on x64, and these files only compile to 32bit. So there could be performance missing there.rdmd --force -I../ -m32 -O -inline -release benchmark.d 26.00s user 0.23s system 99% cpu 26.386 total---2048 md2 in 1003 milliseconds: 15

Re: -noboundscheck

2012-08-19 Thread 1100110
Yeah, I figured it out. I did have to rename src though... I ran a few tests, inconclusive for any serious difference. gdc is now compiling with -O3 -march=native -frelease -fno-bounds-check -finline -ffast-math. But no, dmd has the shortest compile times, gdmd the longest. I'm timing everyt

D1: Passing 0x00000000 value to a Windows COM function

2012-08-19 Thread jicman
Greetings. I am trying to pass a (I think) dchar value to a Windows COM function and it does not work. Imagine this situation... dchar test() { dchar val = 0x; return val } void main() { ...lots of code excluded SomeWindowsComCall(test); // this call does not work SomeWindows

Re: -noboundscheck

2012-08-19 Thread Nvirjskly
On Sunday, 19 August 2012 at 21:11:13 UTC, 1100110 wrote: I have gdc, dmd, and ldc installed on my computer. I also forked your repo two minutes before reading this. Tell me what you want, and Ill run whatever tests you want. But in return, I'm stealing your whirlpool.(with attribution of cou

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
The infinite loop was my mistake. I was looking at your outer while loop but because you use exceptions instead of return values it indeed throws an exception, my bad :) By replacing ref by const ref my program slowed down (looked over a period of 10_000 runs). Not considerably but noticeable. Com

Re: -noboundscheck

2012-08-19 Thread 1100110
I have gdc, dmd, and ldc installed on my computer. I also forked your repo two minutes before reading this. Tell me what you want, and Ill run whatever tests you want. But in return, I'm stealing your whirlpool.(with attribution of course.)

Re: std.complex will replace the built-in types

2012-08-19 Thread Jonathan M Davis
On Sunday, August 19, 2012 20:28:35 teo wrote: > I read at http://dlang.org/phobos/std_complex.html that "Complex will > eventually replace the built-in types cfloat, cdouble, creal, ifloat, > idouble, and ireal". > > Can someone elaborate why? What is wrong with the above types? I think that it

Re: -noboundscheck

2012-08-19 Thread Jonathan M Davis
On Sunday, August 19, 2012 22:13:15 Nvirjskly wrote: > Ah, that makes a lot of sense. If my goal is a fast running time > would it then make sense to use another compiler? I heard that > gdc development is lagging behind and that ldc might not even > support D2 all that well? Both gdc and ldc supp

std.complex will replace the built-in types

2012-08-19 Thread teo
I read at http://dlang.org/phobos/std_complex.html that "Complex will eventually replace the built-in types cfloat, cdouble, creal, ifloat, idouble, and ireal". Can someone elaborate why? What is wrong with the above types?

Re: -noboundscheck

2012-08-19 Thread Nvirjskly
On Sunday, 19 August 2012 at 20:07:32 UTC, Jonathan M Davis wrote: On Sunday, August 19, 2012 21:29:38 Nvirjskly wrote: Compiling my code with the -noboundscheck flag sped it up by almost 5 times (whilst passing all tests and working exactly the same way,) is bounds checking really that expens

Re: Where to place function attributes?

2012-08-19 Thread Era Scarecrow
On Sunday, 19 August 2012 at 07:57:15 UTC, Jeremy DeHaan wrote: This probably isn't specifically a D only question as I've seen this in C++ too, but does it make any kind of difference where an attribute is placed when writing a function? I've gotten in a habit of putting it to the right. s

Re: -noboundscheck

2012-08-19 Thread Jonathan M Davis
On Sunday, August 19, 2012 21:29:38 Nvirjskly wrote: > Compiling my code with the -noboundscheck flag sped it up by > almost 5 times (whilst passing all tests and working exactly the > same way,) is bounds checking really that expensive, and what > other simple optimisations can I preform other tha

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread Era Scarecrow
On Sunday, 19 August 2012 at 09:39:53 UTC, maarten van damme wrote: Great, I tried to get rid of the dynamic array "possibilities" by representing it using a static array of bools. This approach made it 4 times faster :) When I have a solid wifi connection I'm going to install dmd 2.60 to com

Re: -noboundscheck

2012-08-19 Thread bearophile
Nvirjskly: is bounds checking really that expensive, The D front-end is very dumb in this, as far as I know it makes no attempts to remove those tests where they can't fail. Walter believes such optimizations don't gain much. what other simple optimisations can I preform other than -inli

Re: Where to place function attributes?

2012-08-19 Thread Simen Kjaeraas
On Sun, 19 Aug 2012 10:15:42 +0200, Jonathan M Davis wrote: it's generally considered good practice to put const and immutable on the right-hand side. I would also say that putting function attributes on a separate line above the function is fairly common: const @property pure int foo()

-noboundscheck

2012-08-19 Thread Nvirjskly
Compiling my code with the -noboundscheck flag sped it up by almost 5 times (whilst passing all tests and working exactly the same way,) is bounds checking really that expensive, and what other simple optimisations can I preform other than -inline -O -noboundscheck?

stdlib.exit()

2012-08-19 Thread David
I have to "exit" the running program, in C I would call #include exit(0); in Python: sys.exit(0); What's the correct way to do that in D? My current implementation: import core.runtime : Runtime; import core.stdc.stdlib : exit; Runtime.terminate(); exit(0); But that doesn't seem correct.

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
my code is located at http://dpaste.dzfl.pl/93cd5f45 2012/8/19, maarten van damme : > Great, i tried to get rid of the dynamic array "possibilities" by > representing it using a static array of bools. This approach made it 4 > times faster :) > > When i have a solid wifi connection I'm going to in

Re: CT Busy Beaver

2012-08-19 Thread Ali Çehreli
On 08/19/2012 07:07 AM, bearophile wrote: Ali Çehreli: Took me a while! Phew... :) http://dpaste.dzfl.pl/6b362382 I have back-ported your changes to my version, and it works (with few improvements, a larger Busy Beaver, etc): http://dpaste.dzfl.pl/0791bea9 --- I have a

Re: CT Busy Beaver

2012-08-19 Thread Ali Çehreli
On 08/19/2012 04:44 AM, bearophile wrote: > Most of your code is very similar to mine, but I can also see many > little differences, so it seems you have written your translation from > scratch. Yes, I've decided to start from scratch. I did look at yours after struggling for some time and I wa

Re: CT Busy Beaver

2012-08-19 Thread David Nadlinger
On Sunday, 19 August 2012 at 14:18:45 UTC, bearophile wrote: You get an optlink crash. I don't know if this is fit for Bugzilla. Any crashes should be submitted to Bugzilla, regardless of what input produced them. And besides that, the code presented here is actually quite short for a linker

Re: CT Busy Beaver

2012-08-19 Thread bearophile
(some programs related to this have given me optilink errors, In the latest version I've shown if you replace this in the larger Busy Beaver: struct TransitionTable(int sym, state) { With a template: template TransitionTable(int sym, state) { You get an optlink crash. I don't know if this

Re: CT Busy Beaver

2012-08-19 Thread bearophile
Ali Çehreli: Took me a while! Phew... :) http://dpaste.dzfl.pl/6b362382 I have back-ported your changes to my version, and it works (with few improvements, a larger Busy Beaver, etc): http://dpaste.dzfl.pl/0791bea9 --- I have also tried to replace your code like thi

Re: CT Busy Beaver

2012-08-19 Thread bearophile
Ali Çehreli: Took me a while! Phew... :) http://dpaste.dzfl.pl/6b362382 I had lots of trouble matching the template specialization that I needed. And a million silly mistakes of mine. Anyway... Produces the same output. It's tricky code :-) But it's a nice exercise for C++11 template pr

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
Great, i tried to get rid of the dynamic array "possibilities" by representing it using a static array of bools. This approach made it 4 times faster :) When i have a solid wifi connection I'm going to install dmd 2.60 to compile timon's code. In the meantime I've started beautifying the source so

Re: Where to place function attributes?

2012-08-19 Thread Jonathan M Davis
On Sunday, August 19, 2012 09:57:14 Jeremy DeHaan wrote: > This probably isn't specifically a D only question as I've seen > this in C++ too, but does it make any kind of difference where an > attribute is placed when writing a function? No. Any function attribute can go on either side, and which

Where to place function attributes?

2012-08-19 Thread Jeremy DeHaan
This probably isn't specifically a D only question as I've seen this in C++ too, but does it make any kind of difference where an attribute is placed when writing a function? example class C { immutable void foo() { //code } } vs class D { void foo() immutable {