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

2022-07-31 Thread frame via Digitalmars-d-learn
On Monday, 1 August 2022 at 04:24:41 UTC, 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

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

2022-07-31 Thread ikelaiah via Digitalmars-d-learn
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 input file 4. append the string

Re: How to check if a class has a specific overload for member x?

2022-07-31 Thread Hipreme via Digitalmars-d-learn
On Sunday, 31 July 2022 at 19:25:51 UTC, Hipreme wrote: I wish to generate some functions using mixin template and I wish to check if the current class already has an specific overload with parameters (A, B). What I'm currently trying is doing `__traits(getOverloads, T, "foo")`, and then

Re: Interfacing with user-supplied binary or obj file

2022-07-31 Thread frame via Digitalmars-d-learn
On Sunday, 31 July 2022 at 10:55:58 UTC, TheZipCreator wrote: So I'm making an interpreter for my custom scripting language and I want to allow users to write libraries in languages other than said scripting language (for efficiency). For example, you should be able to write a mathematics

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

How to check if a class has a specific overload for member x?

2022-07-31 Thread Hipreme via Digitalmars-d-learn
I wish to generate some functions using mixin template and I wish to check if the current class already has an specific overload with parameters (A, B). What I'm currently trying is doing `__traits(getOverloads, T, "foo")`, and then checking if its type are equal. But it seems hackish, and I

Re: Obsecure problem 1

2022-07-31 Thread pascal111 via Digitalmars-d-learn
On Sunday, 31 July 2022 at 17:03:59 UTC, Salih Dincer wrote: On Sunday, 31 July 2022 at 15:01:21 UTC, pascal111 wrote: I don't know how "assert" works, if you explained it I'll be able to get the idea of your suggestion to apply the appropriate changes on my code. **// This code runs

Re: Obsecure problem 1

2022-07-31 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 31 July 2022 at 15:01:21 UTC, pascal111 wrote: I don't know how "assert" works, if you explained it I'll be able to get the idea of your suggestion to apply the appropriate changes on my code. **// This code runs forever:** ```d string str; assert(str is null); str =

Re: Obsecure problem 1

2022-07-31 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 31 July 2022 at 14:52:03 UTC, FeepingCreature wrote: Note sure if I'm misunderstanding, but: D does not copy strings on value passing, because they're inherently reference types. You can think of a string (or any array) as a `struct { size_t length; T* ptr; }` combined with a bunch

Re: Obsecure problem 1

2022-07-31 Thread pascal111 via Digitalmars-d-learn
On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote: On Sunday, 31 July 2022 at 00:58:47 UTC, pascal111 wrote: Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d I have a few more suggestions for you; Among them the first is on the following

Re: Obsecure problem 1

2022-07-31 Thread FeepingCreature via Digitalmars-d-learn
On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote: Why are you using const for strings? After all, they are protected by immutable. Moreover, since you do not use refs, copies are taken in every function and also you have created extra copy for results. Note sure if I'm

Interfacing with user-supplied binary or obj file

2022-07-31 Thread TheZipCreator via Digitalmars-d-learn
So I'm making an interpreter for my custom scripting language and I want to allow users to write libraries in languages other than said scripting language (for efficiency). For example, you should be able to write a mathematics library in D, compile it, then write a simple wrapper in my

Re: Obsecure problem 1

2022-07-31 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 31 July 2022 at 00:58:47 UTC, pascal111 wrote: Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d I have a few more suggestions for you; Among them the first is on the following sample: ```d auto sentence_x = "she has six oxen"; auto