Re: Parallel For

2021-06-14 Thread seany via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 06:39:24 UTC, seany wrote: I know that c# has parallel for [like this](https://dotnettutorials.net/lesson/parallel-for-method-csharp/) . [...] PS : I need the entire include list - while they are not necessary for this minimal example - they are needed for the fu

Parallel For

2021-06-14 Thread seany via Digitalmars-d-learn
I know that c# has parallel for [like this](https://dotnettutorials.net/lesson/parallel-for-method-csharp/) . I know that D has parallel foreach [like this](http://ddili.org/ders/d.en/parallelism.html). I want to do the following : Given 4 sets , A = {a_1, a_2, ... }; B = {b_1, b_2, ... } ;

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 04:24:09 UTC, surlymoor wrote: At the moment, I feel that as long as the stashed front element isn't too "big" (For some definition of big, I guess.), that built-in caching should be fine. But is this acceptable? What's the best practice for determining which range

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread ag0aep6g via Digitalmars-d-learn
On 15.06.21 07:17, mw wrote: https://dlang.org/library/std/range/primitives/front.html the 2nd decl: dchar front(T) (   scope const(T)[] a ) pure @property @safe if (isAutodecodableString!(T[])); you can see `const` but https://dlang.org/library/std/range/primitives/pop_front.html void popFr

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread surlymoor via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 05:17:06 UTC, mw wrote: I think there is another convention (although it's not formally enforced, but should be) is: -- `obj.front() [should be] const`, i.e. it shouldn't modify `obj`, so can be called multiple times at any given state, and produce the same result

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread mw via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 05:03:45 UTC, surlymoor wrote: On Tuesday, 15 June 2021 at 04:57:45 UTC, mw wrote: In English, `front` is a noun, `popFront` have a verb in it, so you know who should do more work :-) Sure, but, for example, the front method of Phobos' MapResult is the one applying

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread surlymoor via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 04:57:45 UTC, mw wrote: In English, `front` is a noun, `popFront` have a verb in it, so you know who should do more work :-) Sure, but, for example, the front method of Phobos' MapResult is the one applying the predicate to the source's front. There's a clear separ

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread mw via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 04:24:09 UTC, surlymoor wrote: All my custom range types perform all their meaningful work in their respective popFront methods, in addition to its expected source data iteration duties. The reason I do this is because I swear I read in a github discussion that front

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread surlymoor via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 04:43:38 UTC, jfondren wrote: Well, consider this program: ```d import std; struct Noisy { int[] source; int pops, fronts; bool empty() { return source.empty; } void popFront() { writeln("popFront #", ++pops); source.popFront; } int front() { wri

Re: In general, who should do more work: popFront or front?

2021-06-14 Thread jfondren via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 04:24:09 UTC, surlymoor wrote: All my custom range types perform all their meaningful work in their respective popFront methods, in addition to its expected source data iteration duties. The reason I do this is because I swear I read in a github discussion that front

In general, who should do more work: popFront or front?

2021-06-14 Thread surlymoor via Digitalmars-d-learn
All my custom range types perform all their meaningful work in their respective popFront methods, in addition to its expected source data iteration duties. The reason I do this is because I swear I read in a github discussion that front is expected to be O(1), and the only way I can think to ac

Re: Unpacking Slices

2021-06-14 Thread jfondren via Digitalmars-d-learn
On Monday, 14 June 2021 at 18:08:27 UTC, Justin Choi wrote: Is there any shortcut for unpacking slices like I'd want to do in a scenario like this? `info = readln.strip.split;` `string a = info[0], b = info[1], c = info[2];` This doesn't leave you with multiple local variables, but it leaves

Re: Unpacking Slices

2021-06-14 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 14 June 2021 at 18:08:27 UTC, Justin Choi wrote: Is there any shortcut for unpacking slices like I'd want to do in a scenario like this? `info = readln.strip.split;` `string a = info[0], b = info[1], c = info[2];` I tried to implement PHP's "list" language construct here, which doe

Re: Unpacking Slices

2021-06-14 Thread Ali Çehreli via Digitalmars-d-learn
On 6/14/21 11:08 AM, Justin Choi wrote: Is there any shortcut for unpacking slices like I'd want to do in a scenario like this? `info = readln.strip.split;` `string a = info[0], b = info[1], c = info[2];` D does not have automatic unpacking. Here is a quick, dirty, and fun experiment: struc

Unpacking Slices

2021-06-14 Thread Justin Choi via Digitalmars-d-learn
Is there any shortcut for unpacking slices like I'd want to do in a scenario like this? `info = readln.strip.split;` `string a = info[0], b = info[1], c = info[2];`

Re: Dynamically allocated Array mutable but non resizeable

2021-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/21 11:09 AM, Jalil David Salamé Messina wrote: I'm searching for a way to do something like this in D: ```cpp struct MyStruct {   const size_t length;   int *const data;   MyStruct(size_t n) : length(n) {     data = new int[length];   } } ``` This way it is mutable, but non resize

Re: Predicates Within Strings

2021-06-14 Thread jfondren via Digitalmars-d-learn
On Monday, 14 June 2021 at 15:01:01 UTC, Justin Choi wrote: Could somebody explain or point me to documentation that helps to explain the usage of strings in predicates? My main question is how D infers the omitted variable specifications given otherwise - for example: `filter!(a => a < 3)(arr)

Dynamically allocated Array mutable but non resizeable

2021-06-14 Thread Jalil David Salamé Messina via Digitalmars-d-learn
I'm searching for a way to do something like this in D: ```cpp struct MyStruct { const size_t length; int *const data; MyStruct(size_t n) : length(n) { data = new int[length]; } } ``` This way it is mutable, but non resizeable: ```cpp MyStruct s = MyStruct(10); s.data[0] = 42;

Predicates Within Strings

2021-06-14 Thread Justin Choi via Digitalmars-d-learn
Could somebody explain or point me to documentation that helps to explain the usage of strings in predicates? My main question is how D infers the omitted variable specifications given otherwise - for example: `filter!(a => a < 3)(arr);` and `filter!"a < 3"(arr);` produce the same result.

cast to pure function stop work after upgrade

2021-06-14 Thread baby_tiger via Digitalmars-d-learn
this used work for me, after upgrade I get this error. how to fix it ? import std.traits; enum LogLevel : ubyte { INFO = 0, WARN, ERROR, FATAL, } extern (C) string VFORMAT(LogLevel

UDAs on function calls or return locations?

2021-06-14 Thread Mike Brown via Digitalmars-d-learn
Hi all, Is it possible to add a UDA onto either the function call, and detect its present? or onto the variable that the result will go to? E.g. auto int x = function() @UDA; int function() { if (hasUDA(call_site)) { ... } } or @UDA int y = function(); int function() {

Re: Wrote a Protobuf-like D (de)serialisation library - asking for comments / suggestions

2021-06-14 Thread Sinisa Susnjar via Digitalmars-d-learn
On Monday, 14 June 2021 at 07:14:27 UTC, Imperatorn wrote: Is it on dub? published it just now :)

Re: Wrote a Protobuf-like D (de)serialisation library - asking for comments / suggestions

2021-06-14 Thread Sinisa Susnjar via Digitalmars-d-learn
On Sunday, 13 June 2021 at 00:18:56 UTC, Ali Çehreli wrote: - If a struct contains all bitwise copyable members, instead of (de)serializing each member individually, the whole struct can by memcpy'ed. This may be a performance gain especially for arrays of structs: You can memcpy the whole arr

Re: cannot take address of scope local in safe function

2021-06-14 Thread ag0aep6g via Digitalmars-d-learn
On 13.06.21 19:49, vit wrote: Is possible create and use scope output range allocated on stack in @safe code? Example: ```d //-dip1000     struct OutputRange{     private bool valid = true;     private void* ptr;     int count = 0;     void put(Val)(auto ref scope Val val

Re: Financial Library

2021-06-14 Thread WebFreak001 via Digitalmars-d-learn
On Sunday, 13 June 2021 at 12:46:29 UTC, Financial Wiz wrote: What are some of the best Financial Libraries for D? I would like to be able to aggregate as much accurate information as possible. Thanks. if you want a type-safe money handling type, try https://code.dlang.org/packages/money

Re: Wrote a Protobuf-like D (de)serialisation library - asking for comments / suggestions

2021-06-14 Thread Imperatorn via Digitalmars-d-learn
On Saturday, 12 June 2021 at 21:59:13 UTC, Sinisa Susnjar wrote: Hi, D newbie here, The library is on par with Google Protobuf performance-wise and does not need a pre-compiler like Protobuf does, but instead uses the meta programming facilities of D to (de)serialise D data types from/to bina

Re: Financial Library

2021-06-14 Thread mw via Digitalmars-d-learn
On Monday, 14 June 2021 at 06:47:01 UTC, Financial Wiz wrote: Ok, what I'm talking about by Financial library is mainly aggregating data in to D from sources that provide them such as yahoo or google so I can do what I want with the data. http/ftp client library, inspired by python-requests ht