Re: Unexpected behavior when casting away immutable

2015-09-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 11:38:38 UTC, Mafi wrote: On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin wrote: On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: ... ``` immutable int x = 10; int* px = cast(int*) *px = 9; writeln(x); ``` It prints 10,

dis...@dlang.org

2015-09-23 Thread Aidan via Digitalmars-d-learn
I am just starting to look into D and i have to say I am loving it at the moment. But I have ran into an issue that i can't seem to find any libraries for Api hooking. If anyone knows of a well documented source for this it would be much appreciated.

Re: Unexpected behavior when casting away immutable

2015-09-23 Thread Mafi via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin wrote: On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: ... ``` immutable int x = 10; int* px = cast(int*) *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-23 Thread Dicebot via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 14:34:07 UTC, bachmeier wrote: I was not aware that you could "violate" immutable. In that case, it's not immutable. You can violate absolutely everything in a system language with casts and pointers. That is exactly what makes it system language. But you

Re: Unexpected behavior when casting away immutable

2015-09-23 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 14:34:07 UTC, bachmeier wrote: On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin wrote: violating immutable is undefined behaviour, so the compiler is technically speaking free to assume it never happens. At the very least, neither snippet's

Re: scope in function argument

2015-09-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 17:09:40 UTC, Freddy wrote: What does it mean when there is a scope in a function argument. That you are not supposed to let that reference escape the function scope. The compiler does little verification of this right now, but may optimize on that

scope in function argument

2015-09-23 Thread Freddy via Digitalmars-d-learn
What does it mean when there is a scope in a function argument. --- void func(scope int* a){} ---

Re: scope in function argument

2015-09-23 Thread Ali Çehreli via Digitalmars-d-learn
On 09/23/2015 10:11 AM, Adam D. Ruppe wrote: > On Wednesday, 23 September 2015 at 17:09:40 UTC, Freddy wrote: >> What does it mean when there is a scope in a function argument. > > That you are not supposed to let that reference escape the function > scope. Just to complete with a related

Re: Dub package with C code

2015-09-23 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 04:17:14 UTC, Rikki Cattermole wrote: Is libxlsxwriter available in the systems package manager? Pacman says no. Let e.g. Windows users figure theirs out. libxlsxwriter is not supported on windows. Which is kind-of funny.

Re: dis...@dlang.org

2015-09-23 Thread Ali Çehreli via Digitalmars-d-learn
On 09/23/2015 06:01 AM, Aidan wrote: I am just starting to look into D and i have to say I am loving it at the moment. But I have ran into an issue that i can't seem to find any libraries for Api hooking. If anyone knows of a well documented source for this it would be much appreciated. I

Re: dis...@dlang.org

2015-09-23 Thread novice2 via Digitalmars-d-learn
http://forum.dlang.org/thread/hrzfcjrltftgzansd...@forum.dlang.org https://github.com/Trass3r/hooksample

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

2015-09-23 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: /**

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

2015-09-23 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

Re: Why is the constructor of B called?

2015-09-23 Thread tcak via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: I wouldn't expect B's constructor to be called at all unless "super" is used there. "If no call to constructors via this or super appear in a constructor, and

Re: Why is the constructor of B called?

2015-09-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: I wouldn't expect B's constructor to be called at all unless "super" is used there. "If no call to constructors via this or super appear in a constructor, and the base class has a constructor, a call to super() is inserted at the

Re: Is there a smart way to process a range of range by front ?

2015-09-23 Thread BBasile via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:04:44 UTC, Justin Whear wrote: On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: I was thinking to a general *interleave()* algorithm for any compatible Range of Range but I can't find any smart way to process each sub range by front Can you show a

Re: Is there a smart way to process a range of range by front ?

2015-09-23 Thread Justin Whear via Digitalmars-d-learn
On Wed, 23 Sep 2015 21:17:27 +, BBasile wrote: > On Wednesday, 23 September 2015 at 21:04:44 UTC, Justin Whear wrote: >> On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: >> >>> I was thinking to a general *interleave()* algorithm for any >>> compatible Range of Range but I can't find any

Re: Is there a smart way to process a range of range by front ?

2015-09-23 Thread BBasile via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:17:29 UTC, BBasile wrote: On Wednesday, 23 September 2015 at 21:04:44 UTC, Justin Whear wrote: On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: I was thinking to a general *interleave()* algorithm for any compatible Range of Range but I can't find any

Re: Is there a smart way to process a range of range by front ?

2015-09-23 Thread BBasile via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:24:22 UTC, Justin Whear wrote: On Wed, 23 Sep 2015 21:17:27 +, BBasile wrote: On Wednesday, 23 September 2015 at 21:04:44 UTC, Justin Whear wrote: On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: I was thinking to a general *interleave()* algorithm

Re: Why is the constructor of B called?

2015-09-23 Thread Ali Çehreli via Digitalmars-d-learn
On 09/23/2015 02:25 PM, tcak wrote: On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: I wouldn't expect B's constructor to be called at all unless "super" is used there. "If no call to constructors via this or

Is there a smart way to process a range of range by front ?

2015-09-23 Thread BBasile via Digitalmars-d-learn
I was thinking to a general *interleave()* algorithm for any compatible Range of Range but I can't find any smart way to process each sub range by front, eg: --- void interleave(RoR)(RoR r) { r.each!(a => a.writeln); } void main() { auto r = [[0,2],[1,3]]; interleave(r); } ---

Why is the constructor of B called?

2015-09-23 Thread tcak via Digitalmars-d-learn
[code] import std.stdio; class B { this() { writeln("B.constructor"); foo(); } void foo() { writeln("B.foo"); } } class D : B { this() { writeln("D.constructor"); } override

Re: Is there a smart way to process a range of range by front ?

2015-09-23 Thread Justin Whear via Digitalmars-d-learn
On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: > I was thinking to a general *interleave()* algorithm for any compatible > Range of Range but I can't find any smart way to process each sub range > by front Can you show a sample input and output to clarify what you mean by interleave? It's

Re: Dub package with C code

2015-09-23 Thread Rikki Cattermole via Digitalmars-d-learn
On 24/09/15 2:43 PM, Sebastiaan Koppe wrote: I have just created bindings for libxlsxwriter, an c library for creating excel files. Used the htod tool to do most of the work, and only had to adjust some things - mainly because libxlsxwriter uses data structures written in macro's. Right now I

Dub package with C code

2015-09-23 Thread Sebastiaan Koppe via Digitalmars-d-learn
I have just created bindings for libxlsxwriter, an c library for creating excel files. Used the htod tool to do most of the work, and only had to adjust some things - mainly because libxlsxwriter uses data structures written in macro's. Right now I am making a dub package and I would like

Re: Is there a smart way to process a range of range by front ?

2015-09-23 Thread Martin Nowak via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:30:37 UTC, BBasile wrote: auto interleave(RoR)(RoR r) { return r.transposed.join; If you use joiner it will even be lazy and avoid the allocation.

Re: Why is the constructor of B called?

2015-09-23 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 23, 2015 at 03:25:04PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 09/23/2015 02:25 PM, tcak wrote: > >On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: > >>On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: > >>>I wouldn't expect B's

Re: Why is the constructor of B called?

2015-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:25:15 UTC, tcak wrote: On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: I wouldn't expect B's constructor to be called at all unless "super" is used there. "If no call to