DMD phobos built with contracts check for win?

2015-05-04 Thread Dzugaru via Digitalmars-d-learn
I have to compile it myself from sources or is it available somewhere? Was playing with fibers using VisualD + DMD and lack of contract checking (for example call() on fiber in state TERM) leads to bizarre crashes :(

Re: Is it safe to reset HOLD fiber?

2015-05-03 Thread Dzugaru via Digitalmars-d-learn
On Sunday, 3 May 2015 at 14:36:04 UTC, Martin Nowak wrote: On Sunday, 3 May 2015 at 12:33:36 UTC, Dzugaru wrote: Actually the documentation answers your question, please help to improve it if you don't find it clear enough. http://dlang.org/phobos/core_thread.html#.Fiber.reset Created a

Is it safe to reset HOLD fiber?

2015-05-03 Thread Dzugaru via Digitalmars-d-learn
Documentation says This fiber must be in state TERM. but in the core.thread I see In contract only on reset without parameters (bug maybe?) and with HOLD condition too: assert( m_state == State.TERM || m_state == State.HOLD ); Does that mean its ok to reset the fiber if I'm not using things

Re: Is it safe to reset HOLD fiber?

2015-05-03 Thread Dzugaru via Digitalmars-d-learn
Just did another test and it seems its not safe at all. Reusing the fibers with reset without properly exiting the function leads to eventual stack overflow.

Template argument deduction from a function call question

2015-04-01 Thread Dzugaru via Digitalmars-d
Following recent IRC discussion. I want to write a generic list aggregate function that works with builtin types like int[] as well as custom classes/structs that define front, empty, popFront: import std.range; ElementType!S aggregate(alias func, S)(S list, ElementType!S accum =

Re: Template argument deduction from a function call question

2015-04-01 Thread Dzugaru via Digitalmars-d
On Wednesday, 1 April 2015 at 18:13:15 UTC, Ali Çehreli wrote: On 04/01/2015 10:57 AM, Dzugaru wrote: ElementType!S aggregate(alias func, S)(S list, ElementType!S accum = ElementType!S.init) if(is(typeof(func(accum, accum)) == typeof(accum))) { [...] } I can't explain exactly why that

Re: Template argument deduction from a function call question

2015-04-01 Thread Dzugaru via Digitalmars-d
a) isn't this almost, if not exactly, the same as std.algorithm.reduce? b) you can write nice things like this: auto min = [2,4,1,3,5].aggregate!((a, b) = a b ? a : b)(int.max); c) the deduction failure looks like a bug to me, perhaps there is a good reason why it can't work in the

Re: Template argument deduction from a function call question

2015-04-01 Thread Dzugaru via Digitalmars-d
On Wednesday, 1 April 2015 at 18:37:24 UTC, Ali Çehreli wrote: On 04/01/2015 11:27 AM, Dzugaru wrote: This code does work when you provide second (non-default) argument to function, and doesn't if you do not (no way it can deduce E solely from checks I assume). My version, in constract,