Re: SumType extraction

2024-07-06 Thread Christian Köstlin via Digitalmars-d-learn
On Thursday, 27 June 2024 at 18:51:19 UTC, Josh Holtrop wrote: Questions: 4. Any other general improvements to my solution? I know it's kind of an unpopular choice these days but one could go with inheritance and polymorphism or instanceof tests. something along the lines of ```d import

Re: Partial function application (Currying)

2024-01-20 Thread Christian Köstlin via Digitalmars-d-learn
Would https://dlang.org/library/std/functional/curry.html help you? kind regards, Christian

Re: Synchronisation help

2024-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 10:41:55 UTC, Anonymouse wrote: On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: [...] Thank you. Yes, `Foo` is a class for the purposes of inheritance -- I left that out of the example. So a completely valid solution is to write a struct

Re: How to implement filterMap

2023-12-30 Thread Christian Köstlin via Digitalmars-d-learn
On Saturday, 30 December 2023 at 18:08:55 UTC, Alexandru Ermicioi wrote: On Friday, 29 December 2023 at 23:10:47 UTC, Christian Köstlin wrote: Is there a way to implement filterMap (meaning do mapping of a range, but if something happens during the map, leave this element out of the resulting

Re: How to implement filterMap

2023-12-30 Thread Christian Köstlin via Digitalmars-d-learn
On Saturday, 30 December 2023 at 01:22:31 UTC, Siarhei Siamashka wrote: On Friday, 29 December 2023 at 23:10:47 UTC, Christian Köstlin wrote: Is there a way to implement filterMap (meaning do mapping of a range, but if something happens during the map, leave this element out of the resulting

How to implement filterMap

2023-12-29 Thread Christian Köstlin via Digitalmars-d-learn
Is there a way to implement filterMap (meaning do mapping of a range, but if something happens during the map, leave this element out of the resulting range). I have two solutions (one is with evaluating the mapping function several times), and one tries to store the result for the next front

Re: Non-blocking keyboard input

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 14:41:05 UTC, Christian Köstlin wrote: One option (not tested) should be to close stdin so that readln then returns null or something on eof. Shutting down threads is always tricky. It would be great if there would be one or two (perhaps one synchronous, one

Re: Non-blocking keyboard input

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 05:07:04 UTC, Joe wrote: ??? Surely there there is a one liner library solution for this? I have a program that spawns a thread for debugging information and uses the keyboard input which allows me to display the

Re: Behaves different on my osx and linux machines

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 14:03:06 UTC, Kagamin wrote: Maybe you're not supposed to print text while reading? In parallel I have contacted schveiguy on discord and he found the culprid. But we do not have a solution yet. It probably will result in a bugreport at

Re: Behaves different on my osx and linux machines

2023-12-22 Thread Christian Köstlin via Digitalmars-d-learn
On Friday, 22 December 2023 at 15:02:42 UTC, Kagamin wrote: Add more debugging? ``` bool done = false; while (!done) { writeln(1); auto result = ["echo", "Hello World"].execute; if (result.status != 0) { writeln(2); throw

Behaves different on my osx and linux machines

2023-12-21 Thread Christian Köstlin via Digitalmars-d-learn
I have this somehow reduced program that behaves differently on osx and linux. ```d void stdioMain() { import std.stdio : readln, writeln; import std.concurrency : spawnLinked, receive, receiveTimeout, LinkTerminated; import std.variant : Variant; import std.string : strip;

Re: How do I install a package globally?

2023-11-13 Thread Christian Köstlin via Digitalmars-d-learn
On Saturday, 11 November 2023 at 23:28:18 UTC, Trevor wrote: On Saturday, 11 November 2023 at 07:12:21 UTC, Christian Köstlin wrote: On Saturday, 11 November 2023 at 01:50:54 UTC, Trevor wrote: I'm just getting in to D , coming from a C and Python background. I've had a play with DUB

Re: How do I install a package globally?

2023-11-10 Thread Christian Köstlin via Digitalmars-d-learn
On Saturday, 11 November 2023 at 01:50:54 UTC, Trevor wrote: I'm just getting in to D , coming from a C and Python background. I've had a play with DUB and adding packages to my project, but it seems like there should be a way to install packages so they can be used in any D program I compile

Re: Weird bug in std.logger? Possible memory corruption

2023-11-01 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 1 November 2023 at 14:15:55 UTC, matheus wrote: On Tuesday, 31 October 2023 at 21:19:34 UTC, Arafel wrote: ... Assigning the value to a variable works as expected: ```d import std.logger : info; void main() { auto s = foo(); info(s); } auto foo() { info("In foo");

Re: Removing an element from a DList

2023-10-18 Thread Christian Köstlin via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 17:27:19 UTC, Joakim G. wrote: For some reason I cannot remove an element from a DList. I tried several range approaches but to no avail. I'm a noob. In the end I did this: ``` private void removeFromWaitingQueue(uint jid) { auto arr = waitingQueue[].array;

Re: Vibe.d download function, how to get callback when done or error?

2023-09-24 Thread Christian Köstlin via Digitalmars-d-learn
On 24.09.23 12:01, j...@bloow.edu wrote: On Saturday, 23 September 2023 at 20:20:31 UTC, Christian Köstlin wrote: On 23.09.23 14:07, j...@bloow.edu wrote: I'm using download(url, filename) to download files in vibe.d. The issue is that I do not know when the download is finished or errors

Re: Vibe.d download function, how to get callback when done or error?

2023-09-24 Thread Christian Köstlin via Digitalmars-d-learn
On 24.09.23 12:01, j...@bloow.edu wrote: On Saturday, 23 September 2023 at 20:20:31 UTC, Christian Köstlin wrote: On 23.09.23 14:07, j...@bloow.edu wrote: I'm using download(url, filename) to download files in vibe.d. The issue is that I do not know when the download is finished or errors

Re: Vibe.d download function, how to get callback when done or error?

2023-09-23 Thread Christian Köstlin via Digitalmars-d-learn
On 23.09.23 14:07, j...@bloow.edu wrote: I'm using download(url, filename) to download files in vibe.d. The issue is that I do not know when the download is finished or errors. There is a callback for the streaming side but not for the file download. A small test program shows, that if the

Re: change object class

2023-09-23 Thread Christian Köstlin via Digitalmars-d-learn
On 23.09.23 05:11, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: another option could be to model your own VTable in a struct like this: https://run.dlang.io/is/3LTjP5 Kind regards, Christian Thank, Christian ! True nice tasty solution

Re: change object class

2023-09-23 Thread Christian Köstlin via Digitalmars-d-learn
On 23.09.23 05:25, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! You could model it oop style like this: https://run.dlang.io/is/MJb5Fk This solution might not be to your taste, as it involves

Re: change object class

2023-09-22 Thread Christian Köstlin via Digitalmars-d-learn
On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! I want to change a method ```Draw``` on a custom object when the ```MouseIn``` event occurs. This is known as "Change State" of the object: ```Init``` -> ```Hovered```. I want to change the state of an object by changing its class, like this: ```d

Re: Json Help

2023-09-12 Thread Christian Köstlin via Digitalmars-d-learn
On 10.09.23 13:06, Vino wrote: Hi All,   Request your help on the below code,I am trying to convert the below string to json and it always throws the error, if the below can be accomplished with any other json package even that is fine, I tired only the std.json package. Test Program:

Re: pipeProcess output to hash string

2023-09-11 Thread Christian Köstlin via Digitalmars-d-learn
On 09.09.23 17:44, Vino wrote: Hi All,   Request your help on how to convert the output of std.process.pipeProcess to hash string ``` auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr) {     import std.process;     import std.digest.crc;     import std.stdio: writeln;   

Re: parallel threads stalls until all thread batches are finished.

2023-08-29 Thread Christian Köstlin via Digitalmars-d-learn
On 29.08.23 00:37, j...@bloow.edu wrote: Well, I have 32 cores so that would spawn 64-1 threads with hyper threading so not really a solution as it is too many simultaneous downs IMO. "These properties get and set the number of worker threads in the TaskPool instance returned by taskPool.

Re: parallel threads stalls until all thread batches are finished.

2023-08-28 Thread Christian Köstlin via Digitalmars-d-learn
On 26.08.23 05:39, j...@bloow.edu wrote: On Friday, 25 August 2023 at 21:31:37 UTC, Ali Çehreli wrote: On 8/25/23 14:27, j...@bloow.edu wrote: > "A work unit is a set of consecutive elements of range to be processed > by a worker thread between communication with any other thread. The > number

Re: Giant template - changing types everywhere

2023-07-14 Thread Christian Köstlin via Digitalmars-d-learn
On 14.07.23 18:51, Steven Schveighoffer wrote: On 7/14/23 12:40 PM, Christian Köstlin wrote: Would Eponymous Templates (https://dlang.org/spec/template.html#implicit_template_properties) work with the wrapping template? Only if all the functions are named the same as the template

Re: Giant template - changing types everywhere

2023-07-14 Thread Christian Köstlin via Digitalmars-d-learn
On 14.07.23 16:15, Steven Schveighoffer wrote: On 7/14/23 1:51 AM, Cecil Ward wrote: On Friday, 14 July 2023 at 05:09:58 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 05:05:27 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 05:03:31 UTC, Cecil Ward wrote: The way I can see it going is

Re: Mixin and compile-time functions for code generation

2023-06-30 Thread Christian Köstlin via Digitalmars-d-learn
On 24.06.23 18:31, Cecil Ward wrote: I have a function that can be run at compile-time and which will be able to output code to be injected into the D source code stream. Can I get mixin whatever to do this for me? Mixin with a function that runs at compile-time and creates the required source

Re: serve-d and emacs

2023-04-20 Thread Christian Köstlin via Digitalmars-d-learn
I tried to reproduce my old eglot experiment, and for me serve-d was not even compiling with the newest dmd. Which versions are you using? Kind regards, Christian

How do you work with unittest libraries in dub packages?

2023-04-04 Thread Christian Köstlin via Digitalmars-d-learn
Recently Dmytro Katyukha brought up an issue in one of my dub packages that is supposed to be used as a library. He even went the whole way and came up with a simple reduced example: https://gitlab.com/gizmomogwai/colored/-/merge_requests/3#note_1341026928. The problem here is, that my dub

How to work with phobos github projects

2023-03-10 Thread Christian Köstlin via Digitalmars-d-learn
Recently I was looking in contributing to dlang/phobos and found the github subprojects for phobos (https://github.com/dlang/phobos/projects?type=classic) which include a project to improve the public examples for phobos (https://github.com/dlang/phobos/projects/1). I looked at one of the

Re: Simplest way to convert an array into a set

2023-02-13 Thread Christian Köstlin via Digitalmars-d-learn
On 13.02.23 19:04, Matt wrote: Obviously, there is no "set" object in D, but I was wondering what the quickest way to remove duplicates from an array would be. I was convinced I'd seen a "unique" method somewhere, but I've looked through the documentation for std.array, std.algorithm AND

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-23 Thread Christian Köstlin via Digitalmars-d-learn
On 24.01.23 04:59, thebluepandabear wrote: Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone to help me because of that... but any sort of assistance or leads would be greatly... greatly apprecaited... I do not know anything about

Re: Coding Challenges - Dlang or Generic

2023-01-12 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.23 23:30, Paul wrote: On Tuesday, 10 January 2023 at 01:31:28 UTC, Ali Çehreli wrote: On 1/9/23 16:17, Paul wrote: > coding challenges Perhaps the following two?   https://rosettacode.org/   https://adventofcode.com/ Ali Excellent.  Thanks. For this years advent-of-code Steven

Re: Coding Challenges - Dlang or Generic

2023-01-12 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.23 23:22, monkyyy wrote: On Tuesday, 10 January 2023 at 19:10:09 UTC, Christian Köstlin wrote: On 10.01.23 01:17, Paul wrote: There is also https://exercism.org/tracks/d with some tasks for dlang. Kind regards, Christian Its all converted code; worthless I was not aware

Re: Coding Challenges - Dlang or Generic

2023-01-10 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.23 01:17, Paul wrote: There is also https://exercism.org/tracks/d with some tasks for dlang. Kind regards, Christian

Advent of Code 2022

2022-12-10 Thread Christian Köstlin via Digitalmars-d-learn
Is anybody participating with dlang in the advent of code 22? It would be interesting to discuss dlang specific things from the puzzles. Kind regards, Christian

Re: Gotcha with photos' documentation

2022-12-09 Thread Christian Köstlin via Digitalmars-d-learn
On 09.12.22 19:55, H. S. Teoh wrote: On Fri, Dec 09, 2022 at 12:51:27PM +0100, Christian Köstlin via Digitalmars-d-learn wrote: On 09.12.22 02:27, H. S. Teoh wrote: [...] https://github.com/dlang/phobos/pull/8646 [...] Thanks a lot ... that was fast. It only took a minute to fix. :-D

Re: Gotcha with photos' documentation

2022-12-09 Thread Christian Köstlin via Digitalmars-d-learn
On 09.12.22 02:27, H. S. Teoh wrote: On Thu, Dec 08, 2022 at 05:21:52PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] I'll see if I can reword this to be more explicit. [...] https://github.com/dlang/phobos/pull/8646 T Thanks a lot ... that was fast. Is there also an

Gotcha with photos' documentation

2022-12-08 Thread Christian Köstlin via Digitalmars-d-learn
Recently I stumbled upon a small issue in dlang's docs. I wanted to look up uniq in std.algorithm. Started from https://dlang.org/phobos/std_algorithm.html and clicked uniq, no problem, all good. But my code did not work. After some debugging I saw, that for some inputs uniq just did not work.

Is it just me, or does vibe.d's api doc look strange?

2022-12-02 Thread Christian Köstlin via Digitalmars-d-learn
Please see this screenshot: https://imgur.com/Ez9TcqD of my browser (firefox or chrome) of https://vibed.org/api/vibe.web.auth/ Kind regards, Christian

Re: Makefiles and dub

2022-11-05 Thread Christian Köstlin via Digitalmars-d-learn
On 05.11.22 12:38, rikki cattermole wrote: We have a few build formats that dub can generate for you automatically: ``` visuald - VisualD project files sublimetext - SublimeText project file cmake - CMake build scripts build - Builds the package directly ``` Unfortunately none of them are

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 17:24, Kagamin wrote: Another idea is to separate the script and interpreter then compile them together. ``` --- interp.d --- import script; import ...more stuff ...boilerplate code int main() {   interpret(script.All);   return 0; } --- script.d --- #! ? module script; import

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 20:16, H. S. Teoh wrote: On Wed, Nov 02, 2022 at 03:08:36PM +, JN via Digitalmars-d-learn wrote: On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: sh("touch %s".format(t.name)); One of the problems of many Make-

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 04:07, rikki cattermole wrote: Something to consider: dub can be used as a library. You can add your own logic in main to allow using your build specification to generate a dub file (either in memory or in file system). Nice ... I will perhaps give that a try! Kind regards,

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 03:25, Tejas wrote: On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: Dear dlang-folk, one of the tools I always return to is rake (https://ruby.github.io/rake/). For those that do not know it, its a little like make in the sense that you describe your build

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 00:51, Adam D Ruppe wrote: I don't have specific answers to your questions but your goal sounds similar to Atila's reggae project so it might be good for you to take a look at: https://code.dlang.org/packages/reggae Hi Adam, thanks for the pointer. I forgot about reggae ;-) From

Make IN Dlang

2022-11-01 Thread Christian Köstlin via Digitalmars-d-learn
Dear dlang-folk, one of the tools I always return to is rake (https://ruby.github.io/rake/). For those that do not know it, its a little like make in the sense that you describe your build as a graph of tasks with dependencies between them, but in contrast to make the definition is written in

Re: rotate left an array

2022-10-04 Thread Christian Köstlin via Digitalmars-d-learn
If you are ok with using things from std.range you could use something like this: ```d import std.range : cycle, drop, take; import std.stdio : writeln; int main(string[] args) { auto r = [1, 2, 3, 4, 5, 6, 7, 8]; writeln(r.cycle.drop(3).take(r.length)); return 0; } ``` Kind

Re: Is there a way to mark a dub package as linux only?

2022-09-27 Thread Christian Köstlin via Digitalmars-d-learn
On 27.09.22 13:07, Ahmet Sait wrote: On Monday, 26 September 2022 at 20:57:06 UTC, Christian Köstlin wrote: Or posix only? Or not windows? Kind regards, Christian Not necessarily a dub solution but you can do something like this: ```d version(Posix) { } else     static assert(0

Is there a way to mark a dub package as linux only?

2022-09-26 Thread Christian Köstlin via Digitalmars-d-learn
Or posix only? Or not windows? Kind regards, Christian

Anaphoric "macros"

2022-09-24 Thread Christian Köstlin via Digitalmars-d-learn
Hi, I just stumbled upon anaphoric macros (https://en.wikipedia.org/wiki/Anaphoric_macro) in elisp. Seems that the dlang feature e.g. `map!"a*2"` is something similar to that, although I never read about it phrased like that before. Kind regards, Christian

Re: Setting import paths - project (dub) and also rdmd or dmd

2022-09-19 Thread Christian Köstlin via Digitalmars-d-learn
On 19.09.22 16:24, David wrote: Hi, New to D (and enjoying the learning..) I've probably missed something obvious but I'm slightly confused with the best way to achieve a simple build. I like to keep my reusable modules in a directory outside of the project directory so I can use them on

Re: dub lint

2022-09-16 Thread Christian Köstlin via Digitalmars-d-learn
On 16.09.22 02:23, rikki cattermole wrote: https://github.com/dlang/dub/issues/2483 Also the double --config option is already in a bugreport (quite old), but not fixed as far as i can see: https://github.com/dlang/dub/issues/1940 Kind regards, Christian

Re: dub lint

2022-09-15 Thread Christian Köstlin via Digitalmars-d-learn
On 16.09.22 01:14, Christian Köstlin wrote: On 16.09.22 00:14, Ali Çehreli wrote: On 9/15/22 15:04, Ali Çehreli wrote:  > Is there a way to silence specific 'dub lint' warnings? Answering myself, I don't think it's possible but luckily my catching an Error was in unittests only so I can

Re: dub lint

2022-09-15 Thread Christian Köstlin via Digitalmars-d-learn
On 16.09.22 00:14, Ali Çehreli wrote: On 9/15/22 15:04, Ali Çehreli wrote: > Is there a way to silence specific 'dub lint' warnings? Answering myself, I don't think it's possible but luckily my catching an Error was in unittests only so I can do either of the following to skip unittest code

Re: How check if destructor has been called?

2022-09-13 Thread Christian Köstlin via Digitalmars-d-learn
On 13.09.22 19:13, Ben Jones wrote: On Tuesday, 13 September 2022 at 14:06:42 UTC, Injeckt wrote: Hi, I'm trying to check if destructor has been called, but when I'm deleting class object I didn't get any calls from destructor. myclass.d     ~this() {     this.log("\nDestructor\n");  

How do you work with lst files?

2022-08-24 Thread Christian Köstlin via Digitalmars-d-learn
I want to ask around how you from the dlang community work with .lst coverage files? For me those files are really one of the best formats as they are (really, in contrast to some xml things) human readable and someone added them to codecov. My setup at the moment consists of a small tool

Re: Recommendation for parallelism with nested for loops?

2022-08-20 Thread Christian Köstlin via Digitalmars-d-learn
On 20.08.22 12:28, Christian Köstlin wrote: On 19.08.22 03:49, Shriramana Sharma wrote: Hello. I want to parallelize a computation which has two for loops, one nested within another. All inner-loop-param+outer-loop-param combinations can be computed independent of one another. As I suspected

Re: Recommendation for parallelism with nested for loops?

2022-08-20 Thread Christian Köstlin via Digitalmars-d-learn
On 19.08.22 03:49, Shriramana Sharma wrote: Hello. I want to parallelize a computation which has two for loops, one nested within another. All inner-loop-param+outer-loop-param combinations can be computed independent of one another. As I suspected,

Re: How to use exceptions

2022-08-13 Thread Christian Köstlin via Digitalmars-d-learn
On 13.08.22 17:00, kdevel wrote: "Exception enrichment" would be my wording which is supported by google [1]. There is also the notion of "exception context" [2] and "contexted exception" [3]. Thats really a good word! Especially it describes better what the java guys are doing by adding

Re: How to use exceptions

2022-08-13 Thread Christian Köstlin via Digitalmars-d-learn
On 13.08.22 15:00, kdevel wrote: On Friday, 12 August 2022 at 21:41:25 UTC, Christian Köstlin wrote: which would enable something like ```d     return  s     .readText     .parseJSON     .contextWithException((UTFException e) {     return new Exception("Cannot proces

Re: How to use exceptions

2022-08-12 Thread Christian Köstlin via Digitalmars-d-learn
On 12.08.22 23:05, Christian Köstlin wrote: On 12.08.22 01:50, H. S. Teoh wrote: ... > The OP's idea of wrapping throwing code with a function that tacks on extra information is a good idea.  Perhaps the use of strings isn't ideal, but in principle I like his idea of exceptions acquir

Run dub build with all generated files in /tmp

2022-08-12 Thread Christian Köstlin via Digitalmars-d-learn
Sometimes I do not only rely on git to transport dub projects from computer to computer, but also on Dropbox or Syncthing or similar tools. For that it would be great if it would be possible to do all dub commands (e.g. build) in a way, that they are not touching the current working directory.

Re: How to use exceptions

2022-08-12 Thread Christian Köstlin via Digitalmars-d-learn
On 12.08.22 01:50, H. S. Teoh wrote: ... > The OP's idea of wrapping throwing code with a function that tacks on extra information is a good idea. Perhaps the use of strings isn't ideal, but in principle I like his idea of exceptions acquiring higher-level information as it propagates up the

Re: How to use exceptions

2022-08-11 Thread Christian Köstlin via Digitalmars-d-learn
On 12.08.22 01:06, Adam D Ruppe wrote: You might find my recent blog post interesting too: http://dpldocs.info/this-week-in-d/Blog.Posted_2022_08_01.html#exception-template-concept and a draft of some more concepts: http://arsd-official.dpldocs.info/source/arsd.exception.d.html I also find

How to use exceptions

2022-08-11 Thread Christian Köstlin via Digitalmars-d-learn
Dear d-lang experts, lets say in general I am quite happy with exceptions. Recently though I stumbled upon two problems with them: 1. Its quite simple to loose valuable information 2. Its hard to present the exception messages to end users of your program Let me elaborate on those: Lets take

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-08-01 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-08-01 06:24, ikelaiah wrote: Hi, I've written a cli tool to merge JSON files (containing JSON array) in the current folder as a single JSON file. My algorithm: 1. Create a string to store the output JSON array as a string, 2. read each file 3. read each object in JSON array from

How to work with coverage data

2022-07-31 Thread Christian Köstlin via Digitalmars-d-learn
Hi dlang lovers, I recently wanted to improve how I work with coverage data (locally). For that I came up with a small program, that can be either called after a `dub test --coverage` or that can be automatically executed after the unittest with `postRunCommands "$DUB run lst2errormessages"`

Re: Fetching licensing info for all dependencies of a DUB project

2022-06-29 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-06-28 14:34, Guillaume Piolat wrote: On Monday, 27 June 2022 at 21:36:31 UTC, Christian Köstlin wrote: I played around with the idea and came up with a small dub package, that is not (yet) uploaded to the dub registry. Source is available at https://github.com/gizmomogwai/packageinfo

Re: Fetching licensing info for all dependencies of a DUB project

2022-06-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2020-05-12 15:23, Paul Backus wrote: On Tuesday, 12 May 2020 at 13:08:01 UTC, Joseph Rushton Wakeling wrote: On Tuesday, 12 May 2020 at 12:59:14 UTC, Paul Backus wrote: You should be able to get this information from the JSON output of `dub describe`. Cool, thanks.  Much appreciated :-)

Re: Whats the proper way to write a Range next function

2022-06-15 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-06-15 19:36, JG wrote: On Wednesday, 15 June 2022 at 17:30:31 UTC, JG wrote: On Wednesday, 15 June 2022 at 13:52:24 UTC, Christian Köstlin wrote: the naive version would look like ```d auto next(Range)(Range r) {     r.popFront;     return r.front; } ``` But looking at a mature

Whats the proper way to write a Range next function

2022-06-15 Thread Christian Köstlin via Digitalmars-d-learn
the naive version would look like ```d auto next(Range)(Range r) { r.popFront; return r.front; } ``` But looking at a mature library e.g. https://github.com/submada/btl/blob/9cc599fd8495215d346ccd62d6e9f1f7ac140937/source/btl/vector/package.d#L229 is looks like there should be tons of

Re: Templatized delegates

2022-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-31 23:15, Andrey Zherikov wrote: I have tightly coupled code which I'd like to decouple but I'm a bit stuck. For simplicity, I reduced the amount of code to something simple to understand. So I have a struct `S` that has templated member function that does something. On the other

Re: Tracing/Profiling D Applications

2022-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-29 23:00, Ali Çehreli wrote: On 5/29/22 13:53, Christian Köstlin wrote: > According to > https://www.schveiguy.com/blog/2022/05/comparing-exceptions-and-errors-in-d/ > its bad to catch Errors ... Correct in the sense that the program should not continue after catchi

Re: Tracing/Profiling D Applications

2022-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-29 23:08, Ali Çehreli wrote: On 5/29/22 13:47, Christian Köstlin wrote: > Our discussion with using TLS for the > collectors proposed to not need any lock on the add method for > collector, because its thread local and with that thread safe? It would be great

Re: Execute the Shell command and continue executing the algorithm

2022-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-30 15:25, Ali Çehreli wrote: On 5/30/22 04:18, Alexander Zhirov wrote: > I want to run a command in the background The closest is spawnShell: import std.stdio; import std.process; import core.thread; void main() {   auto pid = spawnShell(`(sleep 1 & echo SLEEP >> log)`);  

Re: Tracing/Profiling D Applications

2022-05-29 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-29 20:52, Ali Çehreli wrote: On 5/27/22 06:55, Christian Köstlin wrote: > I wonder how I can synchronize the "dumping" and the > collection of the threads. Would be cool to have an efficient lockless > implementation of appender ... That turned o

Re: Tracing/Profiling D Applications

2022-05-29 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-29 20:52, Ali Çehreli wrote: On 5/27/22 06:55, Christian Köstlin wrote: > I wonder how I can synchronize the "dumping" and the > collection of the threads. Would be cool to have an efficient lockless > implementation of appender ... That turned o

Re: Tracing/Profiling D Applications

2022-05-27 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-26 22:19, Ali Çehreli wrote: On 5/26/22 12:54, Christian Köstlin wrote: > I want to be able to dump > tracings even while the program is still running. Then I would have to > collect the tls data of all still running threads. I am not sure without testing but I

Re: Tracing/Profiling D Applications

2022-05-26 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-25 23:56, Ali Çehreli wrote: On 5/25/22 14:35, Christian Köstlin wrote: > 1. I went for a singleton for storing tracing/logging information that > needs to be initialized manually. Is __gshared the right way to do that? I think this is where thread-local storage comes in

Re: Tracing/Profiling D Applications

2022-05-26 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-26 01:05, frame wrote: On Wednesday, 25 May 2022 at 21:35:07 UTC, Christian Köstlin wrote: Is there also a way to get the "real" threadid? I'm using that functions inside threads: core.sys.windows.winbase.GetCurrentThreadId on Windows core.sys.posix.pthread.pthread_se

Tracing/Profiling D Applications

2022-05-25 Thread Christian Köstlin via Digitalmars-d-learn
I experimented with application level tracing/profiling of d applications similar to what is described in https://dlang.org/blog/2020/03/13/tracing-d-applications/ as the "writef-based approach". Only difference is, that I am emitting json

Re: Help with DynamicArray of Emsi Containers

2022-05-01 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-01 09:12, vit wrote: DynamicArray has disabled postblit (is not copyable). Package autoptr is deprecated (internaly redirected to btl:atuoptr), all functionality is moved to package [BTL](https://code.dlang.org/packages/btl) (subpackage btl:autoptr). This library contains

Help with DynamicArray of Emsi Containers

2022-04-30 Thread Christian Köstlin via Digitalmars-d-learn
I am struggling with initializing an Emsi Containers DynamicArray in a nice way. Some background information of my usecase: I experimenting in porting some old 3d engine code of mine from c++ to dlang. In the engine I want to exactly control when resources are freed and not rely on the

Re: Offline D documentation/tutorial

2022-02-16 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-02-13 01:16, LorenDB wrote: Is there a way to download tour.dlang.org, the D spec, and/or the Phobos spec as an offline HTML site? I like the ability of cppreference.com to be saved as an offline HTML archive and I'd like to have that for D as well. In addition to the already

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

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: 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

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: 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 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-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: 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

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 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: 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

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",

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

  1   2   >