Re: struct init property

2012-08-24 Thread nocide
Am 23.08.2012 19:15, schrieb nocide: struct has no default constructor and instances are initialized with the init property. Can I declare or override the init property for a custom defined struct? Ok, the initializer forks fine for me, but I've encounterd following situation: (simplified code

types of ranges

2012-08-24 Thread Minas Mina
Is there n article that explains the different types of Ranges? (InputRange, ForwardRange, etc) and their usage?

Re: struct init property

2012-08-24 Thread Timon Gehr
On 08/24/2012 09:39 AM, nocide wrote: Am 23.08.2012 19:15, schrieb nocide: struct has no default constructor and instances are initialized with the init property. Can I declare or override the init property for a custom defined struct? Ok, the initializer forks fine for me, but I've encounter

Re: types of ranges

2012-08-24 Thread Jesse Phillips
On Friday, 24 August 2012 at 10:44:28 UTC, Minas Mina wrote: Is there n article that explains the different types of Ranges? (InputRange, ForwardRange, etc) and their usage? There are the docs[1] and this chapter of "Programming in D"[2] 1. http://dlang.org/phobos/std_range.html 2. http://ddil

Re: types of ranges

2012-08-24 Thread Ali Çehreli
On 08/24/2012 03:44 AM, Minas Mina wrote: Is there n article that explains the different types of Ranges? (InputRange, ForwardRange, etc) and their usage? This chapter tries to do that: http://ddili.org/ders/d.en/ranges.html It contains a link to an article by Andrei as well. Ali -- D Pro

Re: float[] → Vertex[] – decreases performance by 1000%

2012-08-24 Thread Benjamin Thaut
Am 24.07.2012 20:38, schrieb David: I am writing a game engine, well I was using a float[] array to store my vertices, this worked well, but I have to send more and more uv coordinates (and other information) which needn't be stored as `float`'s so I moved from a float-Array to a Vertex Array: ht

Re: inout functions

2012-08-24 Thread Kagamin
Well, it may be also a way to ensure the function doesn't modify the struct.

Re: Link against MinGW libraries

2012-08-24 Thread Kagamin
If I remember it correctly, you should write a .def file and compile it with dlltool or something like that. It will create the import library.

Re: Link against MinGW libraries

2012-08-24 Thread Kagamin
There was also a switch for gcc or ld to generate an import library.

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

2012-08-24 Thread maarten van damme
I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. I've probably violated every D guideline concerning the use of static, pure, nothrow,... but it works perfectly :) It does fail to com

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

2012-08-24 Thread Chris Cain
On Friday, 24 August 2012 at 19:32:53 UTC, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. I've probably violated every D guideline concerning the use of

Re: call member function alias

2012-08-24 Thread Ellery Newcomer
On 08/23/2012 11:47 PM, Jacob Carlborg wrote: How about this: import std.stdio; class Foo { auto forward (alias fn, Args...) (Args args) { return fn(args); } void bar (int a = 3) { writeln("bar ", a); } } auto call (alias fn, T, Args...) (T t,

Re: float[] → Vertex[] – decreases performance by 1000%

2012-08-24 Thread David
Check the dissassembly view of this line: buffer[elements++] = Vertex(x, y, z, nx, ny, nz, u, v, u_biome, v_biome); If you are using an old version of dmd it will allocate an block of memory which has the size of Vertex, then it will fill the date into that block of memory, and then memcpy it to

Re: Memory detection

2012-08-24 Thread Dmitry Olshansky
On 24-Aug-12 07:03, 1100110 wrote: On linux this is not so difficult to do. Those values are generally in /proc, and it seems to be portable across pretty much every distro with a relatively recent kernel. I have an extremely half-assed bit of code that prints the load average and the totaly %

Re: Memory detection

2012-08-24 Thread 1100110
On Fri, 24 Aug 2012 15:42:21 -0500, Dmitry Olshansky wrote: On 24-Aug-12 07:03, 1100110 wrote: On linux this is not so difficult to do. Those values are generally in /proc, and it seems to be portable across pretty much every distro with a relatively recent kernel. I have an extremely hal

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

2012-08-24 Thread nazriel
On Friday, 24 August 2012 at 19:32:53 UTC, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. I've probably violated every D guideline concerning the use of

Re: Memory detection

2012-08-24 Thread Dmitry Olshansky
On 25-Aug-12 00:52, 1100110 wrote: On Fri, 24 Aug 2012 15:42:21 -0500, Dmitry Olshansky wrote: On 24-Aug-12 07:03, 1100110 wrote: On linux this is not so difficult to do. Those values are generally in /proc, and it seems to be portable across pretty much every distro with a relatively recen

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

2012-08-24 Thread maarten van damme
Thank you very much. I changed line 119 to an explicit cast to int and removed an unneeded cast at line 63. It now happily compiles with 64bit mode : http://dpaste.dzfl.pl/63666f07. It's kind off odd though that compiling with -inline seems to slow it a bit down. I'm unsure if searching for the fi

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

2012-08-24 Thread maarten van damme
> I'm unsure if searching for the field with the least possibilities was > a smart move because now I have to carry that "taken" array through > all my functions and optimize has to check the whole sudoku instead of > a slice. (come to think of it, taken should've been named occupied) I take that

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

2012-08-24 Thread bearophile
maarten van damme: http://dpaste.dzfl.pl/8a2aef5b Some suggestions about the code: - Put a space before and after operators, after a commas and semicolon, around "..", etc. - Compile with "-wi -property"; - Try to add pure/const/nothrow/immutable where possible; - Minimize the need of cast()

Re: Memory detection

2012-08-24 Thread 1100110
On Fri, 24 Aug 2012 16:05:28 -0500, Dmitry Olshansky wrote: On 25-Aug-12 00:52, 1100110 wrote: On Fri, 24 Aug 2012 15:42:21 -0500, Dmitry Olshansky wrote: On 24-Aug-12 07:03, 1100110 wrote: On linux this is not so difficult to do. Those values are generally in /proc, and it seems to be

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

2012-08-24 Thread bearophile
I will try to replace the int[] of cachedBitsetToRange with something more static, to reduce indirection. Yeah, it's a bit faster, but not a lot: http://dpaste.dzfl.pl/b04a0127 Bye, bearophile

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

2012-08-24 Thread maarten van damme
> Some suggestions about the code: Thank you very much for your criticism, there are indeed a lot of points where I have to improve on. > - Put a space before and after operators, after a commas and semicolon, > around "..", etc. > - Compile with "-wi -property"; > - Try to add pure/const/nothrow/

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

2012-08-24 Thread Timon Gehr
On 08/24/2012 09:32 PM, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. It is 10s vs 13s with GDC on my machine.

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

2012-08-24 Thread maarten van damme
and everythingPossible should also be changed to something ala 2 ^(side) -1

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

2012-08-24 Thread maarten van damme
2012/8/25 Timon Gehr : > On 08/24/2012 09:32 PM, maarten van damme wrote: >> >> I've distiled what I understood from your source and the resulting >> executable managed to solve the impossible one in 27 seconds while >> your source takes 41 seconds. >> > > It is 10s vs 13s with GDC on my machine. >

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

2012-08-24 Thread bearophile
maarten van damme: Is there a special reason I should use them in little programs like these? In my experience small programs contain lot of the issues and ideas contained in large programs. Using things like "pure" and "const/immutable" helps avoid/catch some bugs even in small programs. G

Check for ctfe

2012-08-24 Thread cal
I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)

abnormal program termination

2012-08-24 Thread Ellery Newcomer
I am running into an ICE on windows - Assertion Failure on such-and-such line in mtype.c - and I am trying to get a test command for to reduce it with the redoubtable dustmite. Normally, 'abnormal program termination' is printed to the console; however if I try to redirect stderr for greppage

Re: Check for ctfe

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:06 AM, cal wrote: I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something) if(__ctfe)

Re: Check for ctfe

2012-08-24 Thread bearophile
cal: I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something) It's named __ctfe, but unfortunately it's an (immutable) run-

Re: Check for ctfe

2012-08-24 Thread cal
On Saturday, 25 August 2012 at 00:13:44 UTC, Timon Gehr wrote: On 08/25/2012 02:06 AM, cal wrote: I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static

Re: Check for ctfe

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:15 AM, bearophile wrote: cal: I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something) It's named __ctfe, b

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

2012-08-24 Thread Timon Gehr
On 08/25/2012 01:01 AM, Timon Gehr wrote: On 08/24/2012 09:32 PM, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. It is 10s vs 13s with GDC on my machin

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

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:38 AM, Timon Gehr wrote: On 08/25/2012 01:01 AM, Timon Gehr wrote: On 08/24/2012 09:32 PM, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds

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

2012-08-24 Thread Chris Cain
On Friday, 24 August 2012 at 23:14:02 UTC, maarten van damme wrote: http://en.wikipedia.org/wiki/File:Sudoku_puzzle_hard_for_brute_force.jpg It occurs to me that one of the main reasons why this particular puzzle would be hard for brute force is that the first line is blank and more than half

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

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:51 AM, Chris Cain wrote: On Friday, 24 August 2012 at 23:14:02 UTC, maarten van damme wrote: http://en.wikipedia.org/wiki/File:Sudoku_puzzle_hard_for_brute_force.jpg It occurs to me that one of the main reasons why this particular puzzle would be hard for brute force is that t

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

2012-08-24 Thread Era Scarecrow
On Saturday, 25 August 2012 at 00:51:23 UTC, Chris Cain wrote: On Friday, 24 August 2012 at 23:14:02 UTC, maarten van damme wrote: http://en.wikipedia.org/wiki/File:Sudoku_puzzle_hard_for_brute_force.jpg It occurs to me that one of the main reasons why this particular puzzle would be hard for

how to get fully qualified name of a template function (if possible at CT)

2012-08-24 Thread timotheecour
how to get fully qualified name of a template function? In the code below I want to get "util.mod.mymethod!(double)" I tried everything (see below) to no avail, it just returns "mymethod"; The closest I get is demangle(mangledName!(fun)), which shouldn't be hard to convert to what I want, but de

Re: how to get fully qualified name of a template function (if possible at CT)

2012-08-24 Thread timotheecour
related threads: http://www.digitalmars.com/d/archives/digitalmars/D/learn/3530.html from Don Clugston: I have implemented compile-time demangle metafunctions: static assert( prettynameof!(A)== "class main.A" ); static assert( qualifiednameof!(A) == "main.A" ); static assert( symbolnameof!(A