Re: Template recursion exceeded

2019-02-26 Thread Michelle Long via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 06:56:59 UTC, Nicholas Wilson wrote: On Wednesday, 27 February 2019 at 05:45:19 UTC, Michelle Long wrote: Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expan

Re: How to break from parallel foreach?

2019-02-26 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2019-02-26 at 21:36 +, Jordan Wilson via Digitalmars-d-learn wrote: > On Tuesday, 26 February 2019 at 19:58:24 UTC, Andrey wrote: > > Hello, > > How to break from parallel foreach? > > More general question - how to control such loop? > > A basic way would be to use a flag: > > shared

Re: How to break from parallel foreach?

2019-02-26 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2019-02-26 at 19:58 +, Andrey via Digitalmars-d-learn wrote: > Hello, > How to break from parallel foreach? > More general question - how to control such loop? It is not clear to me that the concept of "breaking" from a parallel loop makes sense. For a sequential loop each loop body i

Re: Template recursion exceeded

2019-02-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 05:45:19 UTC, Michelle Long wrote: Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansion Yep, that return is a dynamic return, not a stat

Template recursion exceeded

2019-02-26 Thread Michelle Long via Digitalmars-d-learn
Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansion

Re: How can we template an alias?

2019-02-26 Thread Michelle Long via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 04:11:09 UTC, Michelle Long wrote: doubles and ints are not upcasted properly to complex foo(Complex!double c) foo(3) fails I'd like to do something like alias CR(t) = Complex!double(t); CR(3) which would be equivalent to typing Complex!double(3) but much

How can we template an alias?

2019-02-26 Thread Michelle Long via Digitalmars-d-learn
doubles and ints are not upcasted properly to complex foo(Complex!double c) foo(3) fails I'd like to do something like alias CR(t) = Complex!double(t); CR(3) which would be equivalent to typing Complex!double(3) but much shorter. Writing a wrapper is overkill.

Re: My template tuple code does not compile

2019-02-26 Thread Victor Porton via Digitalmars-d-learn
After following your suggestion to rewrite it with Stride it does not work either. I assume the error is somehow related to allSatisfy!. https://github.com/vporton/struct-params-dlang/blob/c1adc86672f46fd6b743903cc270dceef120a8fe/source/struct_params.d Please help. It is important for both D c

Re: My template tuple code does not compile

2019-02-26 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 22:56:37 UTC, Victor Porton wrote: On Tuesday, 26 February 2019 at 22:51:15 UTC, Q. Schroll wrote: Grouping arguments could be done, but from my experience, it does not buy you anything; rather it makes it worse. Better just deal with heterogeneous stuff just lik

Re: My template tuple code does not compile

2019-02-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 26, 2019 at 10:56:37PM +, Victor Porton via Digitalmars-d-learn wrote: [...] > After fixing the error you pointed me, it does not work too: > > mixin ProviderParams!("S", ((int, "x"), (float, "y"))); Try this: mixin ProviderParams!("S", int, "x", float, "y"); > Also: C

Re: My template tuple code does not compile

2019-02-26 Thread Victor Porton via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 22:51:15 UTC, Q. Schroll wrote: On Tuesday, 26 February 2019 at 21:43:31 UTC, Victor Porton wrote: Compilation of unittest at the bottom of this file fails with an error. What is my error? ... You have the line ProviderParams("S", ((int, "x"), (float, "y")))

Re: My template tuple code does not compile

2019-02-26 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 21:43:31 UTC, Victor Porton wrote: Compilation of unittest at the bottom of this file fails with an error. What is my error? I cannot tell you, why exactly you get these error messages. I can explain you the probable cause of the errors. I have not tested anyth

My template tuple code does not compile

2019-02-26 Thread Victor Porton via Digitalmars-d-learn
Compilation of unittest at the bottom of this file fails with an error. What is my error? https://github.com/vporton/struct-params-dlang/blob/c32cfde60dbb03cb80a4a8aeb8185f5c86705790/source/struct_params.d It is very important both for this useful little D project and my bigger research projec

Re: How to break from parallel foreach?

2019-02-26 Thread Ali Çehreli via Digitalmars-d-learn
On 02/26/2019 01:36 PM, Jordan Wilson wrote: On Tuesday, 26 February 2019 at 19:58:24 UTC, Andrey wrote: Hello, How to break from parallel foreach? More general question - how to control such loop? A basic way would be to use a flag: shared stopWork=false; foreach (wordBag; wordBags.parallel)

Re: Few questions about staticMap

2019-02-26 Thread Ali Çehreli via Digitalmars-d-learn
On 02/26/2019 10:50 AM, Mitacha wrote: > I checked, just out of curiosity, what is staticMap's implementation. > It's implemented using recursive, this made me think if there is way to > use static foreach instead. I'm pretty sure staticMap was implemented way before 'static foreach'. Perhaps i

Re: How to break from parallel foreach?

2019-02-26 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 19:58:24 UTC, Andrey wrote: Hello, How to break from parallel foreach? More general question - how to control such loop? A basic way would be to use a flag: shared stopWork=false; foreach (wordBag; wordBags.parallel) { if (!stopWork) { // do work

Re: How to break from parallel foreach?

2019-02-26 Thread Alex via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 19:58:24 UTC, Andrey wrote: Hello, How to break from parallel foreach? More general question - how to control such loop? Which expectation do you have on such a break?

How to break from parallel foreach?

2019-02-26 Thread Andrey via Digitalmars-d-learn
Hello, How to break from parallel foreach? More general question - how to control such loop?

Re: Purpose of template DECLARE_HANDLE in druntime

2019-02-26 Thread Andre Pany via Digitalmars-d-learn
On Friday, 1 February 2019 at 08:12:23 UTC, Andre Pany wrote: On Friday, 1 February 2019 at 07:35:34 UTC, Kagamin wrote: It's a strong typed handle, in C it's declared as #ifdef STRICT typedef void *HANDLE; #if 0 && (_MSC_VER > 1000) #define DECLARE_HANDLE(name) struct name##__; typedef struct

Few questions about staticMap

2019-02-26 Thread Mitacha via Digitalmars-d-learn
Hi everyone, I checked, just out of curiosity, what is staticMap's implementation. It's implemented using recursive, this made me think if there is way to use static foreach instead. I came out with following solution: https://run.dlang.io/is/qvgJaw I checked time it took compiler to compile

Re: Odd behavior of darray.dup

2019-02-26 Thread Dmitriy via Digitalmars-d-learn
On Friday, 22 February 2019 at 11:36:35 UTC, solidstate1991 wrote: If I want to copy an array of structs with .dup (cannot post the link in question here at the moment due to non-working clipboard, it's Color from pixelperfectengine.graphics.common) I get all zeroes instead of the values from t

Re: sort!("...") with template function?

2019-02-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 26, 2019 3:06:04 AM MST Simen Kjærås via Digitalmars-d- learn wrote: > On Monday, 25 February 2019 at 15:26:33 UTC, Jonathan M Davis > > wrote: > > On Monday, February 25, 2019 5:47:47 AM MST Simen Kjærås via > > > >> String functions can't access the local scope, and thus can'

Re: DMD2 vs LDC2 inliner

2019-02-26 Thread kinke via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 04:36:59 UTC, James Blachly wrote: Sadly, the pragma does not accept enum: Error: pragma `inline` pragma(inline, true or false) expected, not inline_overlaps That's most likely a (trivial) bug and should be fixed. As stated in the docs, the pragma can also be

Re: Simplifying a string mixin

2019-02-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-02-25 21:57, Victor Porton wrote: Can string mixing be split into several parts? I have a mixin like this:     mixin("struct " ~ name ~ " {\n" ~   "  struct Regular {\n" ~   "    // ..." ~   "  }\n" ~   "  struct WithDefaults {\n" ~   "    /

Re: How to setup dub to use x86 and x64 dll's when appropriate?

2019-02-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-02-26 05:17, Michelle Long wrote: e.g., using sdl for different versions and have it automatically switch. What would be nice is if one could stick all the files for x86 in one dir and x64 in the others and they will be used depending on the build(and copied) Ideally one can do it fo

Re: Simplifying a string mixin

2019-02-26 Thread bauss via Digitalmars-d-learn
On Monday, 25 February 2019 at 21:04:48 UTC, Adam D. Ruppe wrote: On Monday, 25 February 2019 at 20:57:37 UTC, Victor Porton wrote: Can string mixing be split into several parts? I have a mixin like this: mixin("struct " ~ name ~ " {\n" ~ " struct Regular {\n" ~ "/

Re: Simplifying a string mixin

2019-02-26 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 25 February 2019 at 21:04:48 UTC, Adam D. Ruppe wrote: On Monday, 25 February 2019 at 20:57:37 UTC, Victor Porton wrote: Also, what is the most proper thing to check that `name` is a proper identified (not say !@#)? just let the compiler do it imo. Agreed. There are times when err

Re: sort!("...") with template function?

2019-02-26 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 25 February 2019 at 15:26:33 UTC, Jonathan M Davis wrote: On Monday, February 25, 2019 5:47:47 AM MST Simen Kjærås via String functions can't access the local scope, and thus can't see Dummy. Using lambdas works. (string functions were basically a workaround for no decent lambda synt