Re: Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 June 2016 at 21:52:31 UTC, AbstractGuy wrote: On Saturday, 4 June 2016 at 17:16:45 UTC, pineapple wrote: Won't this pattern fail if items is a type implementing opApply and/or opApplyReverse? opApply/ApplyReverse predates the detection of the input/bidir range primitives. It's

Re: throw Exception with custom message in nogc code

2016-06-04 Thread Ali Çehreli via Digitalmars-d-learn
On 06/04/2016 05:05 PM, poliklosio wrote: I need to throw some exceptions in my code, but I don't want to ever care about the garbage collector. I have seen some solutions to throwing exceptions in nogc code, but only toy examples, like https://p0nce.github.io/d-idioms/#Throwing-despite-@nogc

throw Exception with custom message in nogc code

2016-06-04 Thread poliklosio via Digitalmars-d-learn
I need to throw some exceptions in my code, but I don't want to ever care about the garbage collector. I have seen some solutions to throwing exceptions in nogc code, but only toy examples, like https://p0nce.github.io/d-idioms/#Throwing-despite-@nogc The solution sort of works, but doesn't

Re: iota access in foreach loop

2016-06-04 Thread Alex via Digitalmars-d-learn
On Saturday, 4 June 2016 at 18:58:51 UTC, Brad Anderson wrote: On Saturday, 4 June 2016 at 18:55:09 UTC, Brad Anderson wrote: On Saturday, 4 June 2016 at 18:20:26 UTC, Alex wrote: [...] Check out enumerate() in std.range; Ah! thanks! int counter = 5; foreach(i, el;

Re: Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread AbstractGuy via Digitalmars-d-learn
On Saturday, 4 June 2016 at 17:16:45 UTC, pineapple wrote: Won't this pattern fail if items is a type implementing opApply and/or opApplyReverse? opApply/ApplyReverse predates the detection of the input/bidir range primitives. It's specified in the language. If an aggregate implements both

Re: iota access in foreach loop

2016-06-04 Thread Brad Anderson via Digitalmars-d-learn
On Saturday, 4 June 2016 at 18:55:09 UTC, Brad Anderson wrote: On Saturday, 4 June 2016 at 18:20:26 UTC, Alex wrote: [...] Check out enumerate() in std.range; int counter = 5; foreach(i, el; enumerate(randomCover(iota(counter writeln("index: ", i, " element: ", el);

Re: iota access in foreach loop

2016-06-04 Thread Brad Anderson via Digitalmars-d-learn
On Saturday, 4 June 2016 at 18:20:26 UTC, Alex wrote: Hi all! Could you help me clearify why a iota can't be accessed with two arguments in a foreach loop? following tests show my problem: What does work: int[] ku = [0, 1, 2, 3, 4]; foreach(i, el; ku) writeln("index: ", i, "

Re: iota access in foreach loop

2016-06-04 Thread Alex via Digitalmars-d-learn
PPS: The error shown is in line with the iota inside foreach: Error: cannot infer argument types, expected 1 argument, not 2

iota access in foreach loop

2016-06-04 Thread Alex via Digitalmars-d-learn
Hi all! Could you help me clearify why a iota can't be accessed with two arguments in a foreach loop? following tests show my problem: What does work: int[] ku = [0, 1, 2, 3, 4]; foreach(i, el; ku) writeln("index: ", i, " element: ", el); What does not work: counter = 5;

Re: Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread Ali Çehreli via Digitalmars-d-learn
On 06/04/2016 07:32 AM, pineapple wrote: > It would be fantastic if I could write this - > > static if(forward){ > foreach(item; items) dostuff(); > }else{ > foreach_reverse(item; items) dostuff(); > } > > as something like this - > > foreach!forward(item; items)

Re: Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread pineapple via Digitalmars-d-learn
On Saturday, 4 June 2016 at 15:43:01 UTC, Mihail K wrote: As far as I recall, foreach_reverse is deprecated in favour of range operations. ie. import std.algorithm, std.range; static if(forward) { items.each!(item => doStuff()); } else { items.retro.each!(item =>

Re: Overriden method not detected ?

2016-06-04 Thread ag0aep6g via Digitalmars-d-learn
On 06/04/2016 05:02 PM, chmike wrote: Is it possible to instantiate immutable objects by using emplace Yes. I'm not sure, but the memory may have to be untyped for the emplace call to avoid mutating immutable data. I.e., call emplace with void[], not with a pointer whose target is already

Object.factory fails for static libraries

2016-06-04 Thread Andre Pany via Digitalmars-d-learn
Hi, I try to create objects by using the factory method in a static library scenario. file base.d --- module base; class Base { } Object createObject(string name) { return Object.factory(name); } --- file child.d

Re: Bast64URL Error; Invalid character

2016-06-04 Thread xky via Digitalmars-d-learn
On Saturday, 4 June 2016 at 15:27:53 UTC, xky wrote: Hi! First, thank you to those who always answers. I got some DataURL string(it's png image) like this...

Re: Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread Mihail K via Digitalmars-d-learn
On Saturday, 4 June 2016 at 14:32:23 UTC, pineapple wrote: It would be fantastic if I could write this - static if(forward){ foreach(item; items) dostuff(); }else{ foreach_reverse(item; items) dostuff(); } as something like this - foreach!forward(item; items)

Re: Writing adaptor/wrappers with most scalability and least work

2016-06-04 Thread Pie? via Digitalmars-d-learn
On Saturday, 4 June 2016 at 02:10:57 UTC, Adam D. Ruppe wrote: On Saturday, 4 June 2016 at 01:04:08 UTC, Pie? wrote: alias this pImage; It is actually `alias pImage this;` That should do what you want right here. Then you can add your own methods or wrap/disable the image ones one by

Bast64URL Error; Invalid character

2016-06-04 Thread xky via Digitalmars-d-learn
Hi! First, thank you to those who always answers. I got some DataURL string(it's png image) like this... So, i used std.base64

Re: adamdruppe: Drawing scaled image

2016-06-04 Thread Pie? via Digitalmars-d-learn
On Saturday, 4 June 2016 at 02:22:37 UTC, Adam D. Ruppe wrote: On Friday, 3 June 2016 at 20:06:50 UTC, Pie? wrote: Thanks! It is working. A few issues with my images being clipped and not throwing when file doesn't exist... That's weird.. I don't know what's going on there. BTW have you seen

Re: Overriden method not detected ?

2016-06-04 Thread chmike via Digitalmars-d-learn
On Friday, 3 June 2016 at 21:04:41 UTC, ag0aep6g wrote: Thank you ag0aep6g, especially for the missing shared in my static this ! Since I'm implementing a (hopefully useful) library, it would be unpleasant for users to have to cast away shared to print the info. It works with immutable at

Re: D, GTK, Qt, wx,…

2016-06-04 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 4 June 2016 at 08:27:53 UTC, Russel Winder wrote: On Sun, 2016-05-29 at 14:01 +0200, Jordi Sayol via Digitalmars-d-learn wrote: […] https://github.com/nomad-software/tkd I am not a great fan of tk even in Python. It is true that Tk is everywhere and so meets the portability

Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread pineapple via Digitalmars-d-learn
It would be fantastic if I could write this - static if(forward){ foreach(item; items) dostuff(); }else{ foreach_reverse(item; items) dostuff(); } as something like this - foreach!forward(item; items) dostuff(); Is there any way to accomplish this?

How to determine the integrity level ?

2016-06-04 Thread medhi558 via Digitalmars-d-learn
Hello, all I recently need to get the integrity level of a process but i do not know how to do.

Re: improve concurrent queue

2016-06-04 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 27 August 2013 at 19:50:03 UTC, luminousone wrote: I was under the impression that the atomic spinlock has a lower latency for any waiters, then a mutex when its unlocked? I am using this for a temporary or depending on performance, a perminate replacement for std.concurrency

Re: D, GTK, Qt, wx,…

2016-06-04 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2016-05-29 at 14:01 +0200, Jordi Sayol via Digitalmars-d-learn wrote: > […] > https://github.com/nomad-software/tkd > I am not a great fan of tk even in Python. It is true that Tk is everywhere and so meets the portability requirement, but I would still go with Qt (well QML anyway) in

Re: Speed up `dub`.

2016-06-04 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2016-05-24 at 09:00 +0200, Jacob Carlborg via Digitalmars-d- learn wrote: > […] > I think that by default Dub should not check dependencies. There > should  > be an explicit command to install the dependencies. Dub must check all dependencies before starting a build, the question is