Re: Structure initializer VS lambda function

2023-02-19 Thread realhet via Digitalmars-d-learn
Hi again and thanks for the suggestions. I ended up checking every {} block with the following program: It works on a string where all the nested blocks are reduced to a single symbol. For example: '{', '"', '[' And all the comments and whitespaces are reduced to ' ' space. ``` enum CurlyBlock

Transform static immutable string array to tuple.

2023-02-19 Thread realhet via Digitalmars-d-learn
Hello, Is there a better way to transform a string array to a tuple or to an AliasSeq? ``` mixin(customSyntaxPrefixes.format!`tuple(%(%s,%))`) ``` I'd like to use this as variable length arguments passed to the startsWith() std function (as multiple needles).

Re: Transform static immutable string array to tuple.

2023-02-19 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 19 February 2023 at 11:08:34 UTC, realhet wrote: Is there a better way to transform a string array to a tuple or to an AliasSeq? ``` mixin(customSyntaxPrefixes.format!`tuple(%(%s,%))`) ``` https://dlang.org/phobos/std_meta.html#aliasSeqOf

Re: Transform static immutable string array to tuple.

2023-02-19 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Feb 19, 2023 at 11:08:34AM +, realhet via Digitalmars-d-learn wrote: > Hello, > > Is there a better way to transform a string array to a tuple or to an > AliasSeq? > > ``` > mixin(customSyntaxPrefixes.format!`tuple(%(%s,%))`) > ``` > > I'd like to use this as variable length argument

Re: Transform static immutable string array to tuple.

2023-02-19 Thread realhet via Digitalmars-d-learn
Awesome, Thank both of you! ``` enum a = ["A", "B"]; writeln(a); writeln(aliasSeqOf!a); writeln([aliasSeqOf!a]); ```

Re: Debugging memory leaks

2023-02-19 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 18:21:34 UTC, Hipreme wrote: I want to know if there is some way to debug memory leaks in runtime. I have been dealing with that by using a profiler and checking D runtime function calls. Usually those which allocates has high cpu usage so it can be easy for

Big struct/class and T.init

2023-02-19 Thread Guillaume Piolat via Digitalmars-d-learn
If my understanding is correct, the mere fact of having a: struct S { char[16384] array; } And then using it anywhere, will necessarily lead to a S.init being created and linked, leading to a binary size inflation of 16kb. This is not a super high concern, but can inform

Re: Big struct/class and T.init

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 1:11 PM, Guillaume Piolat wrote: If my understanding is correct, the mere fact of having a:     struct S     {     char[16384] array;     } And then using it anywhere, will necessarily lead to a S.init being created and linked, leading to a binary size inflation of 16kb. T

Re: Big struct/class and T.init

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 1:26 PM, Steven Schveighoffer wrote: Testing with run.dlang.io, switching between `char` and `int` changes the ASM output to show whether it's stored or not. And BTW, you can override this by assigning a zero default: ```d struct S { char[16384] array = 0; // no .init storage }

Dub is not finding the dynamic link library MSVCR120.dll...

2023-02-19 Thread WhatMeWorry via Digitalmars-d-learn
and is abending with an error saying exactly this. How do I specify the path to this library? Can I use one of the environment variables in sc.ini, one of the Windows env variables, or one of the dub options? Btw, I'm bypassing on purpose the official D installation.

Re: Big struct/class and T.init

2023-02-19 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 19 February 2023 at 18:29:05 UTC, Steven Schveighoffer wrote: On 2/19/23 1:26 PM, Steven Schveighoffer wrote: Testing with run.dlang.io, switching between `char` and `int` changes the ASM output to show whether it's stored or not. And BTW, you can override this by assigning a zero

Lazy and GC Allocations

2023-02-19 Thread Etienne via Digitalmars-d-learn
Hello, I'm wondering at which moment the following would make an allocation of the scope variables on the GC. Should I assume that the second parameter of enforce being lazy, we would get a delegate/literal that saves the current scope on the GC even if it's not needed? I'm asking purely for

Re: Dub is not finding the dynamic link library MSVCR120.dll...

2023-02-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 February 2023 at 21:05:33 UTC, WhatMeWorry wrote: and is abending with an error saying exactly this. How do I specify the path to this library? Can I use one of the environment variables in sc.ini, one of the Windows env variables, or one of the dub options? Btw, I'm bypassi

Re: Lazy and GC Allocations

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 7:50 PM, Etienne wrote: Hello, I'm wondering at which moment the following would make an allocation of the scope variables on the GC. Should I assume that the second parameter of enforce being lazy, we would get a delegate/literal that saves the current scope on the GC even if it's

Re: Lazy and GC Allocations

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 9:15 PM, Steven Schveighoffer wrote: Indeed, you can't really "save" the hidden delegate somewhere, so the calling function knows that the delgate can't escape. I stand corrected, you can save it (by taking the address of it). And it's explicitly allowed by the spec. But it sti

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-19 Thread forky via Digitalmars-d-learn
On Friday, 10 February 2023 at 07:04:31 UTC, Max Samukha wrote: ... Having class-private doesn't preclude module-private. Dennis even submitted a PR implementing class-private, but it stalled because people couldn't agree on whether class-private should be "private to class" or "private to cl

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-19 Thread FeepingCreature via Digitalmars-d-learn
On Monday, 20 February 2023 at 05:21:44 UTC, forky wrote: On Friday, 10 February 2023 at 07:04:31 UTC, Max Samukha wrote: ... Having class-private doesn't preclude module-private. Dennis even submitted a PR implementing class-private, but it stalled because people couldn't agree on whether cl

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-19 Thread thebluepandabear via Digitalmars-d-learn
But in any case, it should be class private. There have now been three pages produced by three people all agreeing with each other. At what point does it start being spam? Having a discussion !== spam.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-19 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 February 2023 at 06:26:34 UTC, FeepingCreature wrote: There have now been three pages produced by three people all agreeing with each other. At what point does it start being spam? Yes, it's all just noise now. Let's end it here. Further posts in this thread will be deleted