__traits and string mixins

2015-12-03 Thread Christian Köstlin via Digitalmars-d-learn
Hi, I started an experiment with the informations that are available for compile time reflection. What I wanted to create is a thor like cli parser library, that forces you to encapsulate your programs into subclasses of Dli. The commands and options, that are understood by the generated cli

Re: __traits and string mixins

2015-12-04 Thread Christian Köstlin via Digitalmars-d-learn
On 04/12/15 21:49, Nicholas Wilson wrote: On Thursday, 3 December 2015 at 13:36:16 UTC, Christian Köstlin wrote: Hi, I started an experiment with the informations that are available for compile time reflection. [...] I think CyberShadow (aka Vladimir Panteleev) has done something similar to

how to get rid of "cannot deduce function from argument types" elegantly

2016-06-13 Thread Christian Köstlin via Digitalmars-d-learn
I made a small (could be reduced further) example that creates and walks a templated binary tree. The tree also gets a factory function to use type deduction to conveniently construct a tree. Unfortunately this does not compile, if I remove the three ugly methods between /* these should go */

Re: blog.dlang.org

2016-06-21 Thread Christian Köstlin via Digitalmars-d-learn
On 22/06/16 01:51, Seb wrote: > On Tuesday, 21 June 2016 at 23:36:41 UTC, Leandro Motta Barros wrote: >> Try http://dlang.org/blog/ >> >> But, indeed, I would expect blog.dlang.org to work... >> >> Cheers, >> >> LMB >> >> On Tue, Jun 21, 2016 at 6:47 PM, Christian Köstlin < >>

blog.dlang.org

2016-06-21 Thread Christian Köstlin via Digitalmars-d-learn
I just wanted to have a look at the new blog post about ldc, and entered blog.dlang.org without thinking into the browser. This does not lead to the official blog anymore, but to the old digitalmars website.

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Christian Köstlin via Digitalmars-d-learn
On 28/02/2017 01:20, sarn wrote: > On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: >> How can I make sure, that the calculations are done at compile time? > > If you ever have doubts, you can always use something like this to check: > > assert (__ctfe); Thanks a lot,

How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Christian Köstlin via Digitalmars-d-learn
I have a small example, that can be used to express 3601000ms as 1h 1s (a much more advanced version has already been done by https://github.com/nordlow/units-d). I would like to enforce that the precomputation (multiplying and inverting the list of scale's) is done at compile time. Is it enough

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Christian Köstlin via Digitalmars-d-learn
On 01/03/2017 00:09, Joseph Rushton Wakeling wrote: > On Tuesday, 28 February 2017 at 00:22:28 UTC, sarn wrote: >>> If you ever have doubts, you can always use something like this to >>> check: >>> >>> assert (__ctfe); >> >> Sorry, "enforce" would more appropriate if you're really checking. > >

Re: Speed of synchronized

2016-10-18 Thread Christian Köstlin via Digitalmars-d-learn
On 18/10/16 07:04, Daniel Kozak via Digitalmars-d-learn wrote: > dub run --build=release --compiler=ldc on my machine i get the following output (using ldc2) ldc2 --version 09:32 LDC - the LLVM D compiler (1.0.0): based on DMD v2.070.2 and LLVM 3.8.1 built with LDC - the LLVM D compiler

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 17/10/16 14:44, Christian Köstlin wrote: > On 17/10/16 14:09, Daniel Kozak via Digitalmars-d-learn wrote: >> Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): >>> Hi, >>> >>> for an exercise I had to implement a thread safe

Re: Sending Tid in a struct

2016-11-23 Thread Christian Köstlin via Digitalmars-d-learn
On 03/03/2012 18:35, Timon Gehr wrote: > On 03/03/2012 12:09 PM, Nicolas Silva wrote: >> Hi, >> >> I'm trying to send structs using std.concurrency. the struct contains >> a Tid (the id of the sender) so that the receiver can send an answer. >> >> say: >> >> struct Foo >> { >>Tid tid; >>

How to get the name for a Tid

2016-11-23 Thread Christian Köstlin via Digitalmars-d-learn
std.concurrency contains the register function to associate a name with a Tid. This is stored internally in an associative array namesByTid. I see no accessors for this. Is there a way to get to the associated names of a Tid? Thanks, Christian

Speed of synchronized

2016-10-16 Thread Christian Köstlin via Digitalmars-d-learn
Hi, for an exercise I had to implement a thread safe counter. This is what I came up with: ---SNIP--- import std.stdio; import core.thread; import std.conv; import std.datetime; static import core.atomic; import core.sync.mutex; int NR_OF_THREADS = 100; int NR_OF_INCREMENTS = 1; interface

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 16/10/16 19:50, tcak wrote: > On Sunday, 16 October 2016 at 08:41:26 UTC, Christian Köstlin wrote: >> Hi, >> >> for an exercise I had to implement a thread safe counter. This is what >> I came up with: >> >> [...] > > Could you try that: > > class ThreadSafe3Counter: Counter{ > private long

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 17/10/16 06:55, Daniel Kozak via Digitalmars-d-learn wrote: > Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): > >> My question now is, why is each mutex based thread safe variant so slow >> compared to a similar java program? The only hint could be

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 17/10/16 14:09, Daniel Kozak via Digitalmars-d-learn wrote: > Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): >> Hi, >> >> for an exercise I had to implement a thread safe counter. >> This is what I came up with: >> >> >

Re: Multiple producer - multiple consumer with std.concurrency?

2016-12-08 Thread Christian Köstlin via Digitalmars-d-learn
Hi Ali, Thanks for the input, will read about this. About the slowness. I think it also depends on the situation. Sure, every message from all producers/consumers has to go through one MessageBox, but, that is a small critical section, if the work for producing and consuming takes long enough,

Multiple producer - multiple consumer with std.concurrency?

2016-12-07 Thread Christian Köstlin via Digitalmars-d-learn
I really like std.concurrency for message passing style coding. Today I thought about a scenario where I need a multiple producer, multiple consumer pattern. The multiple producer is easily covered by std.concurrency, because all producers just can send to one Tid. The tricky part is the multiple

std.experimental.logger + threadIds

2016-12-19 Thread Christian Köstlin via Digitalmars-d-learn
I am experimenting with the logger interface and want to write a custom logger, that also outputs the threadID or Tid of the LogEntries. The documentation shows how to do a custom logger, but I am unable to convert the threadId to a string, because all conversion functions are not @safe. Is there

Re: std.experimental.logger + threadIds

2016-12-19 Thread Christian Köstlin via Digitalmars-d-learn
On 19/12/2016 21:32, Robert burner Schadek wrote: > The ugly way is to create a @trusted function/lambda that coverts the > threadId to a string. > > Not sure about the pretty way. thanks a lot. works good enough, just for reference, I added: string tid2string(Tid id) @trusted { import

Re: index of ddocs

2017-03-06 Thread Christian Köstlin via Digitalmars-d-learn
On 06/03/2017 11:29, rikki cattermole wrote: > On 06/03/2017 11:25 PM, Christian Köstlin wrote: >> Hi, >> >> I have a small dub-based application project with several modules (it's >> not a vibe.d project). I can easily create ddocs for the modules by >> running dub build --build=docs. >> >> I am

index of ddocs

2017-03-06 Thread Christian Köstlin via Digitalmars-d-learn
Hi, I have a small dub-based application project with several modules (it's not a vibe.d project). I can easily create ddocs for the modules by running dub build --build=docs. I am missing at the moment a page, that shows the contents of the whole package. Did I miss something here? Best

Fiber based UI-Toolkit

2017-07-09 Thread Christian Köstlin via Digitalmars-d-learn
I wonder if there is any fiber based / fiber compatible UI-Toolkit out for dlang. The second question is, if it would make sense at all to have such a thing? christian

Re: Fiber based UI-Toolkit

2017-07-09 Thread Christian Köstlin via Digitalmars-d-learn
On 09.07.17 23:12, bauss wrote: > On Sunday, 9 July 2017 at 19:43:14 UTC, Christian Köstlin wrote: >> I wonder if there is any fiber based / fiber compatible UI-Toolkit out >> for dlang. The second question is, if it would make sense at all to >> have such a thing? >> >> christian > > It doesn't

Re: Fiber based UI-Toolkit

2017-07-10 Thread Christian Köstlin via Digitalmars-d-learn
On 10.07.17 00:23, Christian Köstlin wrote: To elaborate on the previous post, I uploaded a small example, that tries naively to mix dlangui with fibers. Please have a look at: https://github.com/gizmomogwai/fibered-ui.git For sure it does not work. The fiber in the callback is started, but after

Re: Fiber based UI-Toolkit

2017-07-10 Thread Christian Köstlin via Digitalmars-d-learn
On 10.07.17 15:37, Gerald wrote: > On Sunday, 9 July 2017 at 19:43:14 UTC, Christian Köstlin wrote: >> I wonder if there is any fiber based / fiber compatible UI-Toolkit out >> for dlang. The second question is, if it would make sense at all to >> have such a thing? > > As previously noted, like

Whats the most common formatting style for dlang?

2017-07-19 Thread Christian Köstlin via Digitalmars-d-learn
Until now I formatted my toy-programs how I like it. Checking up on dfmt I saw that these deviate from the default settings of dfmt. Does dfmt's default settings reflect the most common style for dlang? Actually I really like all languages, that take out the whole discussion about formatting (like

std.concurrency and sendWithDelay

2017-06-26 Thread Christian Köstlin via Digitalmars-d-learn
I really like the std.concurrency (https://dlang.org/phobos/std_concurrency.html) with spawn, send, receive ... Is there a builtin way to schedule core or an event after a delay (e.g. in android: https://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable, long)

Re: For fun: Expressive C++ 17 Coding Challenge in D

2017-10-15 Thread Christian Köstlin via Digitalmars-d-learn
Another solution using dlangs builtin csv support for reading. import std.csv; import std.file; import std.algorithm : map; import std.range; string csvWrite(Header, Rows)(Header header, Rows rows) { return header.join(",") ~ "\n" ~ rows.map!(r => header.map!(h =>

Re: Behavior of joining mapresults

2017-12-21 Thread Christian Köstlin via Digitalmars-d-learn
On 21.12.17 08:41, Jonathan M Davis wrote: > I would think that it would make a lot more sense to simply put the whole > thing in an array than to use memoize. e.g. > > auto arr = iota(1, 5).map!parse().array(); thats also possible, but i wanted to make use of the laziness ... e.g. if i then

Re: Behavior of joining mapresults

2017-12-20 Thread Christian Köstlin via Digitalmars-d-learn
On 20.12.17 17:30, Christian Köstlin wrote: > thats an idea, thank a lot, will give it a try ... #!/usr/bin/env rdmd -unittest unittest { import std.stdio; import std.range; import std.algorithm; import std.string; import std.functional; auto parse(int i) {

Behavior of joining mapresults

2017-12-20 Thread Christian Köstlin via Digitalmars-d-learn
When working with json data files, that we're a little bigger than convenient I stumbled upon a strange behavior with joining of mapresults (I understand that this is more or less flatmap). I mapped inputfiles, to JSONValues, from which I took out some arrays, whose content I wanted to join.

Re: Behavior of joining mapresults

2017-12-20 Thread Christian Köstlin via Digitalmars-d-learn
On 20.12.17 17:19, Stefan Koch wrote: > On Wednesday, 20 December 2017 at 15:28:00 UTC, Christian Köstlin wrote: >> When working with json data files, that we're a little bigger than >> convenient I stumbled upon a strange behavior with joining of mapresults >> (I understand that this is more or

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Christian Köstlin via Digitalmars-d-learn
On 04.01.18 16:53, Steven Schveighoffer wrote: > On 1/3/18 3:28 PM, Steven Schveighoffer wrote: > >> Stay tuned, there will be updates to iopipe to hopefully make it as >> fast in this microbenchmark as the C version :) > > v0.0.3 has been released. To take advantage of using malloc/realloc, you

Re: Help optimizing UnCompress for gzipped files

2018-01-05 Thread Christian Köstlin via Digitalmars-d-learn
On 05.01.18 15:39, Steven Schveighoffer wrote: > Yeah, I guess most of the bottlenecks are inside libz, or the memory > allocator. There isn't much optimization to be done in the main program > itself. > > D compiles just the same as C. So theoretically you should be able to > get the same

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Christian Köstlin via Digitalmars-d-learn
On 04.01.18 20:46, Steven Schveighoffer wrote: > On 1/4/18 1:57 PM, Christian Köstlin wrote: >> Thanks Steve, >> this runs now faster, I will update the table. > > Still a bit irked that I can't match the C speed :/ > > But, I can't get your C speed to duplicate on my mac even with gcc, so > I'm

Re: Help optimizing UnCompress for gzipped files

2018-01-06 Thread Christian Köstlin via Digitalmars-d-learn
On 05.01.18 23:04, Steven Schveighoffer wrote: > On 1/5/18 3:09 PM, Christian Köstlin wrote: >> On 05.01.18 15:39, Steven Schveighoffer wrote: >>> Yeah, I guess most of the bottlenecks are inside libz, or the memory >>> allocator. There isn't much optimization to be done in the main program >>>

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Christian Köstlin via Digitalmars-d-learn
I added now a c variant, that does always malloc/memcpy/free. Its much slower for sure. Also I put some output in thats shows when a real realloc happens. Its like you said: did a real realloc did a real realloc did a real realloc did a real realloc did a real realloc did a real realloc did not a

Re: Help optimizing UnCompress for gzipped files

2018-01-09 Thread Christian Köstlin via Digitalmars-d-learn
On 07.01.18 14:44, Steven Schveighoffer wrote: > Not from what I'm reading, the C solution is about the same (257 vs. > 261). Not sure if you have averaged these numbers, especially on a real > computer that might be doing other things. yes you are right ... for proper benchmarking proper

Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
Hi all, over the holidays, I played around with processing some gzipped json data. First version was implemented in ruby, but took too long, so I tried, dlang. This was already faster, but not really satisfactory fast. Then I wrote another version in java, which was much faster. After this I

Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 14:51, Adam D. Ruppe wrote: > On Tuesday, 2 January 2018 at 10:27:11 UTC, Christian Köstlin wrote: >> After this I analyzed the first step of the process (gunzipping the >> data from a file to memory), and found out, that dlangs UnCompress is >> much slower than java, and ruby and

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 21:48, Steven Schveighoffer wrote: > On 1/2/18 3:13 PM, Steven Schveighoffer wrote: >> // almost the same line from your current version >> auto mypipe = openDev("../out/nist/2011.json.gz") >>    .bufd.unzip(CompressionFormat.gzip); > > Would you mind telling me the

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 21:13, Steven Schveighoffer wrote: > Well, you don't need to use appender for that (and doing so is copying a > lot of the data an extra time). All you need is to extend the pipe until > there isn't any more new data, and it will all be in the buffer. > > // almost the same line from

Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Christian Köstlin via Digitalmars-d-learn
On 03.01.18 22:33, Steven Schveighoffer wrote: > On 1/3/18 3:28 PM, Steven Schveighoffer wrote: >> 1. The major differentiator between the C and D algorithms is the use >> of C realloc. This one thing saves the most time. I'm going to update >> iopipe so you can use it (stand by). I will also be

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 15:09, Steven Schveighoffer wrote: > On 1/2/18 8:57 AM, Adam D. Ruppe wrote: >> On Tuesday, 2 January 2018 at 11:22:06 UTC, Stefan Koch wrote: >>> You can make it much faster by using a sliced static array as buffer. >> >> Only if you want data corruption! It keeps a copy of your

Is it possible to return the subclass from a method of the parent class in dlang?

2018-03-02 Thread Christian Köstlin via Digitalmars-d-learn
To give an example: class Thread { ... Thread start() {...} } class Timer : Thread { ... } void main() { // Timer timer = new Timer().start; // this does not work auto timer = new Timer().start; // because timer is of type Thread } thanks in advance, christian

Re: Is it possible to return the subclass from a method of the parent class in dlang?

2018-03-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.03.18 21:39, Steven Schveighoffer wrote: > On 3/2/18 3:23 PM, Christian Köstlin wrote: >> To give an example: >> >> class Thread { >>    ... >>    Thread start() {...} >> } >> >> class Timer : Thread { >>    ... >> } >> >> >> void main() { >>    // Timer timer = new Timer().start;  // this

Re: Is it possible to return the subclass from a method of the parent class in dlang?

2018-03-02 Thread Christian Köstlin via Digitalmars-d-learn
>> class Timer : Thread { >>    override Timer start() { ... } >> } >> >> https://dlang.org/spec/function.html#virtual-functions >> >> (see item 6) >> >> -Steve > Thanks for this. > It works for me only without the override (with override I get > Error: function timer.Timer.start does not override

Re: How to get type returned by e.g. std.algorithm.iteration.filter

2019-05-19 Thread Christian Köstlin via Digitalmars-d-learn
Last version using more from the outer template #!/usr/bin/env rdmd import std.stdio; import std.algorithm; import std.typecons; import std.array; import std.range; import std.traits; auto byMinimum(Ranges)(Ranges ranges) { auto getNonEmpty() { return ranges.filter!("!a.empty");

Re: How to get type returned by e.g. std.algorithm.iteration.filter

2019-05-19 Thread Christian Köstlin via Digitalmars-d-learn
On 19.05.19 20:38, Jacob Carlborg wrote: On 2019-05-19 15:36, Christian Köstlin wrote: Unfortunately I have no idea how to even store the result of this search in an attribute of ByMinimum, as I cannot writeout its type. In general you can use `typeof()`, where `` is the expression you want

How to get type returned by e.g. std.algorithm.iteration.filter

2019-05-19 Thread Christian Köstlin via Digitalmars-d-learn
I would like to join several sorted files into one big sorted file. For that I came up with this snippet: #!/usr/bin/env rdmd import std.stdio; import std.algorithm; import std.typecons; import std.array; import std.range; auto byMinimum(Ranges)(Ranges ranges) { auto getNonEmpty() {

Vibe.d and shared data synchronization

2020-04-07 Thread Christian Köstlin via Digitalmars-d-learn
Hi, I wrote a very small vibe.d based URL-shortener. It has an in memory database that is in theory shared across request threads. At the moment I do not distribute over the vibe.d threadpool (https://vibed.org/features#multi-threading), but I would like to. What would be the best way to

Re: dynamic array .length vs .reserve - what's the difference?

2020-08-02 Thread Christian Köstlin via Digitalmars-d-learn
On 31.07.20 06:28, Ali Çehreli wrote: On 7/30/20 4:42 PM, wjoe wrote: > So .capacity can't be assigned a value like length to reserve the RAM ? Yes, a read-only property... >> auto a = b; >> b = b[0 .. $-1]; >> b ~= someT; >> >> If that last line is done in-place, then it overwrites

Re: DMD support for Apples new silicon

2021-01-11 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.21 17:29, Guillaume Piolat wrote: On Sunday, 10 January 2021 at 16:03:53 UTC, Christian Köstlin wrote: Good news! I was hoping for support in ldc, but dmds super fast compile times would be very welcome. I guess it's more work to put an ARM backend there. Kind regards, Christian

Re: DMD support for Apples new silicon

2021-01-10 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.21 15:50, Guillaume Piolat wrote: On Sunday, 10 January 2021 at 14:22:25 UTC, Christian Köstlin wrote: Hi all, are there any plans on supporting Apples new ARM silicon with DMD or would this be something for ldc? Kind regards, Christian Hello Christian, LDC since 1.24+ support

DMD support for Apples new silicon

2021-01-10 Thread Christian Köstlin via Digitalmars-d-learn
Hi all, are there any plans on supporting Apples new ARM silicon with DMD or would this be something for ldc? Kind regards, Christian

Re: Anything in D to avoid check for null everywhere?

2021-01-14 Thread Christian Köstlin via Digitalmars-d-learn
On 12.01.21 22:37, Jack wrote: I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was going to have one but they

Re: Display a random image with vibe.d

2021-06-21 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-06-20 17:14, vnr wrote: On Sunday, 20 June 2021 at 14:28:26 UTC, jfondren wrote: On Sunday, 20 June 2021 at 13:58:22 UTC, vnr wrote: Thanks for the answers, I understand better what is going on. So, what should I do to make my server respond with a random image, and not the random

Re: how do I implement opSlice for retro range?

2021-05-14 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-14 05:49, Jack wrote: How can I implement ranges in the retro range? I'd like to do this without allocate a new array with .array from std.array, can I do that? use like this: ```d     auto arr = [1, 2, 3, 4, 5];     auto a = new A!int(arr);     auto b = a.retro[0 .. 2]; // 4, 5

Re: How to use dub with our own package

2021-05-12 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-12 15:37, Vinod K Chandran wrote: Hi all, I am creating a hobby project related with win api gui functions. i would like to work with dub. But How do I use dub in my project. 1. All my gui library modules are located in a folder named "winglib". 2. And that folder also conatains a d

Re: How to use dub with our own package

2021-05-12 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-12 21:22, Vinod K Chandran wrote: On Wednesday, 12 May 2021 at 18:26:39 UTC, Christian Köstlin wrote: Are you really interested in doing winglib as a separate dub package? If not you could just do a `dub init yourappname` which gives you the basic skeleton. something like: . ├──

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-31 13:40, CandG wrote: On Thursday, 27 May 2021 at 14:44:29 UTC, Steven Schveighoffer wrote: On 5/27/21 10:13 AM, Christian Köstlin wrote: P.S.: I still do not get how to post formatted snippets with thunderbird to the newsgroup/forum :/ It's not possible currently. I no longer

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-31 18:50, Christian Köstlin wrote: On 2021-05-31 13:40, CandG wrote: On Thursday, 27 May 2021 at 14:44:29 UTC, Steven Schveighoffer wrote: On 5/27/21 10:13 AM, Christian Köstlin wrote: P.S.: I still do not get how to post formatted snippets with thunderbird to the newsgroup/forum

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-27 13:11, sighoya wrote: On Thursday, 27 May 2021 at 09:58:40 UTC, Christian Köstlin wrote: I have this small program here test.d: ``` import std; string doSomething(string[] servers, string user) {     return user ~ servers[0]; } void main() {     auto servers = ["s1", "s2", "s3"];

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
Thanks for the proposed solution. It also works in my slightly bigger program (although I do not like to make servers more global). I tried also the following (which unfortunately also does not work as intended): ```D import std; string doSomething(string[] servers, string user) { return

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-27 14:48, sighoya wrote: On Thursday, 27 May 2021 at 12:17:36 UTC, Christian Köstlin wrote: Can you explain me, where here a double context is needed? Because all data now should be passed as arguments to amap? Kind regards, Christian I  believe D's type system isn't smart enough

How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
I have this small program here test.d: ``` import std; string doSomething(string[] servers, string user) { return user ~ servers[0]; } void main() { auto servers = ["s1", "s2", "s3"]; auto users = ["u1", "u2", "u3"]; writeln(map!(user => servers.doSomething(user))(users));

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-27 15:00, sighoya wrote: On Thursday, 27 May 2021 at 12:58:28 UTC, Christian Köstlin wrote: That looks nice, but unfortunately my data for servers and users in the real world is not static but comes from a config file. Okay, but then parametrizing the static lambda with runtime

Re: where do I find the complete phobos function list names ?

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-26 01:46, Paul Backus wrote: On Tuesday, 25 May 2021 at 22:05:16 UTC, someone wrote: I was unsuccessfully searching the site for them in the form of a master index to begin with. I need them, in plain text, in order to add them to a VIM custom syntax highlight plugin I already

Re: where do I find the complete phobos function list names ?

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-26 01:46, Paul Backus wrote: On Tuesday, 25 May 2021 at 22:05:16 UTC, someone wrote: I was unsuccessfully searching the site for them in the form of a master index to begin with. I need them, in plain text, in order to add them to a VIM custom syntax highlight plugin I already

Re: How to work around the infamous dual-context when using delegates together with std.parallelism

2021-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-27 18:56, Ali Çehreli wrote: On 5/27/21 9:19 AM, Ali Çehreli wrote:    auto result = new string[users.length];    users.enumerate.parallel.each!(en => result[en.index] = servers.doSomething(en.value));    writeln(result); I still like the foreach version more:     auto result

serve-d and emacs

2021-04-26 Thread Christian Köstlin via Digitalmars-d-learn
Does anybody use serve-d with emacs (lsp-mode or eglot)? I would love to see the configuration! Kind regards, Christian

Re: serve-d and emacs

2021-04-30 Thread Christian Köstlin via Digitalmars-d-learn
On 26.04.21 21:13, WebFreak001 wrote: On Monday, 26 April 2021 at 18:45:08 UTC, Christian Köstlin wrote: Does anybody use serve-d with emacs (lsp-mode or eglot)? I would love to see the configuration! Kind regards, Christian if you configure it yourself, feel free to share the configuration

Re: serve-d and emacs

2021-04-28 Thread Christian Köstlin via Digitalmars-d-learn
On 26.04.21 21:13, WebFreak001 wrote: On Monday, 26 April 2021 at 18:45:08 UTC, Christian Köstlin wrote: Does anybody use serve-d with emacs (lsp-mode or eglot)? I would love to see the configuration! Kind regards, Christian if you configure it yourself, feel free to share the configuration

Is it possible to exchange the linker with a dub project to use mold

2021-12-22 Thread Christian Köstlin via Digitalmars-d-learn
https://github.com/rui314/mold Kind regards, Christian

Re: Is it possible to exchange the linker with a dub project to use mold

2021-12-22 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-12-22 16:28, Paul Backus wrote: On Wednesday, 22 December 2021 at 15:20:15 UTC, Christian Köstlin wrote: https://github.com/rui314/mold Kind regards, Christian This was recently discussed in the "General" forum: https://forum.dlang.org/thread/fiyfgqykhdmglqypx...@forum.dlang.org

std.concurrency and const

2022-01-05 Thread Christian Köstlin via Digitalmars-d-learn
Hi all, I really like std.concurrency but I now stumbled upon the following. When receiving messages as const, they also need to be sent as const (otherwise they are not matched). Comparing this to normal function calls I would expect a different behavior. ```d import std.concurrency;

Re: std.concurrency and const

2022-01-06 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-01-06 02:55, frame wrote: On Wednesday, 5 January 2022 at 22:22:19 UTC, Christian Köstlin wrote: Hi all, I really like std.concurrency but I now stumbled upon the following. When receiving messages as const, they also need to be sent as const (otherwise they are not matched).