What's wrong with this BinaryHeap declaration line? Assertion failure in std.container.array.d

2015-09-22 Thread Enjoys Math via Digitalmars-d-learn
What I HAD TO do to get it to compile: programResultsQ = heapify!(compareResults, Array!(Results!(O,I)))(Array!(Results!(O,I))([Results!(O,I)()]), 1); programResultsQ.popFront(); What running it says: AssertionFailure at line 381 of std.container.array.d, which looks like: /** Constructor

Re: What's wrong with this BinaryHeap declaration line? Assertion failure in std.container.array.d

2015-09-22 Thread Enjoys Math via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 05:56:08 UTC, Enjoys Math wrote: What I HAD TO do to get it to compile: programResultsQ = heapify!(compareResults, Array!(Results!(O,I)))(Array!(Results!(O,I))([Results!(O,I)()]), 1); programResultsQ.popFront(); What running it says: AssertionFailure at lin

Re: Unexpected behavior when casting away immutable

2015-09-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: I have a situation where I would like to demonstrate violating the contract of immutable (as an example of what not to do), but do so without using structs or classes, just basic types and pointers. The following snippet works

Re: How to setup mono-D for shared libraries?

2015-09-22 Thread Rikki Cattermole via Digitalmars-d-learn
On 23/09/15 8:20 AM, Jacob wrote: How do I setup mono-D for creating shared libraries and including them into other projects? When I drag the .d files to create the library from, which is not my own, I get undefined references. I have the lib files, which are a bunch of separate libs, that I want

Re: Unexpected behavior when casting away immutable

2015-09-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 03:50:44 UTC, Vladimir Panteleev wrote: On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: ``` immutable int x = 10; int* px = cast(int*)&x; *px = 9; writeln(x); ``` It prints 10, where I expected 9. This is on Windows. I'm curious if anyone

Re: Unexpected behavior when casting away immutable

2015-09-22 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: ``` immutable int x = 10; int* px = cast(int*)&x; *px = 9; writeln(x); ``` It prints 10, where I expected 9. This is on Windows. I'm curious if anyone knows why it happens. Essentially, because x is immutable, the compiler op

Unexpected behavior when casting away immutable

2015-09-22 Thread Mike Parker via Digitalmars-d-learn
I have a situation where I would like to demonstrate violating the contract of immutable (as an example of what not to do), but do so without using structs or classes, just basic types and pointers. The following snippet works as I would expect: ``` immutable int i = 10; immutable(int*) pi = &

Re: BidirectionalRange switching direction

2015-09-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 02:10:22 UTC, Tofu Ninja wrote: Trying to implement a bi directional range and it is slightly unclear what the semantics are supposed to be and just wanted some clarification. Are bidirectional ranges supposed to be able to support switching direction mid it

BidirectionalRange switching direction

2015-09-22 Thread Tofu Ninja via Digitalmars-d-learn
Trying to implement a bi directional range and it is slightly unclear what the semantics are supposed to be and just wanted some clarification. Are bidirectional ranges supposed to be able to support switching direction mid iteration? Like if I do popFront popFront popBack should that be equa

How to setup mono-D for shared libraries?

2015-09-22 Thread Jacob via Digitalmars-d-learn
How do I setup mono-D for creating shared libraries and including them into other projects? When I drag the .d files to create the library from, which is not my own, I get undefined references. I have the lib files, which are a bunch of separate libs, that I want to include into one big lib. On

Re: Template detection

2015-09-22 Thread Meta via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 16:11:59 UTC, Alexandru Ermicioi wrote: Thx. Didn't know that there is such trait available. On page http://dlang.org/traits.html it's not present. Yeah, it's undocumented for some reason. Somebody must've forgot to make a corresponding doc pull request I supp

Re: Debugging D shared libraries

2015-09-22 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 22 Sep 2015 14:40:43 + schrieb John Colvin : > On Tuesday, 22 September 2015 at 14:37:11 UTC, Russel Winder > wrote: > > On Sun, 2015-09-20 at 17:47 +0200, Johannes Pfau via > > Digitalmars-d -learn wrote: > >> [...] > > […] > >> [...] > > > > Debian Jessie is far too out of date to

Re: Template detection

2015-09-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 15:37:32 UTC, Meta wrote: On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodOn

Re: Template detection

2015-09-22 Thread Meta via Digitalmars-d-learn
On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodOne() {} void templatedMethodTwo() {} }

Re: Debugging D shared libraries

2015-09-22 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 14:37:11 UTC, Russel Winder wrote: On Sun, 2015-09-20 at 17:47 +0200, Johannes Pfau via Digitalmars-d -learn wrote: [...] […] [...] Debian Jessie is far too out of date to be useful. I'm on Debian Sid (still quite old), and Fedora Rawhide (not quite so old)

Re: Debugging D shared libraries

2015-09-22 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2015-09-20 at 07:49 +, rom via Digitalmars-d-learn wrote: > […] > > works entirely fine. However the "parallel" code: > > > > extern(C) > > double parallel(const int n, const double delta) { > > Runtime.initialize(); > > const pi = 4.0 * delta * taskPool.reduce!"a

Re: Debugging D shared libraries

2015-09-22 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2015-09-20 at 17:49 +0200, Johannes Pfau via Digitalmars-d -learn wrote: > […] > > Just realized this thread is titled "Debugging D shared libraries" ; > -) > GDC does not yet support shared libraries. Conversely I thought it did due to the GCC toolchain thingy. I'm using DMD and LDC jus

Re: Debugging D shared libraries

2015-09-22 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2015-09-20 at 17:47 +0200, Johannes Pfau via Digitalmars-d -learn wrote: > Am Sat, 19 Sep 2015 17:41:41 +0100 > […] > > Have you tried using a newer GDC version? The debian jessie version > probably uses the 2.064.2 frontend. Debian Jessie is far too out of date to be useful. I'm on Debi

Re: Cameleon: Stricter Alternative Implementation of VariantN

2015-09-22 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 12:54:47 UTC, Kagamin wrote: You can generate a union from allowed types, it will make copies type safe too, sort of set!(staticIndexOf(T, AllowedTypes))(rhs)... hmm... can it be an overload? I believe there is a trait somewhere that figures out the maximum al

Re: foreach automoatic counter?

2015-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/21/15 6:49 PM, Jonathan M Davis via Digitalmars-d-learn wrote: In general though, if you want a counter for the range that you're indexing, then you can use lockstep to wrap the range, and then when you use it in foreach, you get the count and the element: http://dlang.org/phobos/std_range.

Re: Cameleon: Stricter Alternative Implementation of VariantN

2015-09-22 Thread Kagamin via Digitalmars-d-learn
You can generate a union from allowed types, it will make copies type safe too, sort of set!(staticIndexOf(T, AllowedTypes))(rhs)... hmm... can it be an overload?

Re: Cameleon: Stricter Alternative Implementation of VariantN

2015-09-22 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 12:47:31 UTC, Per Nordlöw wrote: How does the GC know if the data block contains a reference (pointer) or value type? Does it try to follow that pointer either way!? If so when does this memory scanning occurr?

Re: Cameleon: Stricter Alternative Implementation of VariantN

2015-09-22 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 09:57:58 UTC, Kagamin wrote: Make sure your struct is always sizeof(void*)-aligned. Could that be automatically enforced somehow based on the contents of AllowedTypes?

Re: Cameleon: Stricter Alternative Implementation of VariantN

2015-09-22 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 09:57:58 UTC, Kagamin wrote: - Do I have to call some GC-logic in order to make the GC aware of the new string-reference in `opAssign`? Make sure your struct is always sizeof(void*)-aligned. How does the GC know if the data block contains a reference (pointer

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-22 Thread ponce via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 09:38:12 UTC, thedeemon wrote: I think they don't. Generated .exe seems to depend only on kernel32.dll and shell32.dll, i.e. things users already have. Great then.

Re: Template detection

2015-09-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 13 September 2015 at 09:29:13 UTC, Enamex wrote: On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodO

Re: Has anyone created a D wrapper for wbemuuid.lib

2015-09-22 Thread Kagamin via Digitalmars-d-learn
The bindings are translated from mingw headers, and mingw doesn't supply libraries with precompiled GUIDs, only functions. But bindings for GUIDs are pretty simple: extern extern(System) CLSID CLSID_SWbemLocator; Just copy the names you want.

Re: Has anyone created a D wrapper for wbemuuid.lib

2015-09-22 Thread Thomas Mader via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 10:03:52 UTC, Thomas Mader wrote: Do I miss something? Does anyone have wrapped this lib? This was also asked on stackoverflow some time ago. [1] Wonder if something happend since then. [1] http://stackoverflow.com/questions/24051606/can-i-use-routines-from-co

Has anyone created a D wrapper for wbemuuid.lib

2015-09-22 Thread Thomas Mader via Digitalmars-d-learn
I looked at some of the windows API wrapper projects for D on github [1][2], but none of them seems to have wrapped wbemuuid.lib right now. Do I miss something? Does anyone have wrapped this lib? Thomas [1] http://code.dlang.org/packages/windows-headers [2] https://github.com/smjgordon/binding

Re: Cameleon: Stricter Alternative Implementation of VariantN

2015-09-22 Thread Kagamin via Digitalmars-d-learn
On Monday, 21 September 2015 at 13:42:14 UTC, Nordlöw wrote: Questions: - Is the logic of opAssign and get ok for string? - How does the inner workings of the GC harmonize with my calls to `memcpy` in `opAssign()` here https://github.com/nordlow/justd/blob/master/cameleon.d#L80 That line wo

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-22 Thread thedeemon via Digitalmars-d-learn
On Monday, 21 September 2015 at 15:00:24 UTC, ponce wrote: All in the title. DMD 64-bit links with the VS linker. Do users need to install the VS redistributable libraries? I think they don't. Generated .exe seems to depend only on kernel32.dll and shell32.dll, i.e. things users already have.

Re: Weird behaviour with File.eof

2015-09-22 Thread crimaniak via Digitalmars-d-learn
On Sunday, 20 September 2015 at 20:17:37 UTC, Dandyvica wrote: My file is made of 10 lines: cat numbers.txt 1 2 3 4 5 6 7 8 9 10 ╰─$ wc -l numbers.txt CR/LF can be interpreted as line _dividers_, so if you have CR or CR/LF at the end of line 10, really here is line 11 which is empty. Remove