Re: Replacing tango.text.Ascii.isearch

2022-10-25 Thread rikki cattermole via Digitalmars-d-learn
On 25/10/2022 5:17 PM, Siarhei Siamashka wrote: Wow, I didn't expect anything like this and just thought that the nightmares of handling 8-bit codepages for non-English languages ceased to exist nowadays. Too bad. What are the best practices to deal with Turkish text in D language? std.uni

Re: Supporting foreach (k, v; T.init) for a user-defined (container) type

2022-10-25 Thread Imperatorn via Digitalmars-d-learn
On Monday, 24 October 2022 at 21:52:18 UTC, Ali Çehreli wrote: On 10/24/22 14:26, Per Nordlöw wrote: [...] Another option is to use range functions where front() returns a Tuple. We have an esoteric feature where a tuple expands automatically in foreach loops: import std.typecons : tuple;

Re: Disabling All Inlining in DMD Debug Builds

2022-10-25 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 24 October 2022 at 20:43:45 UTC, ryuukk_ wrote: I wish we could do ``version(DebugFast | Release)`` Moreover, I've been using, for instance, ```d version(D_Coverage) {} else pragma(inline, true); void foo() {} ``` to get correct coverage inclusion of `foo()`. Is this still neeed?

Static executable (ldc, linux)

2022-10-25 Thread Anonymouse via Digitalmars-d-learn
I'm having problems compiling my thing into an executable that doesn't require ldc's phobos/druntime .so's. I want to distribute it in a form where it's okay if `/usr/lib/libphobos2-ldc-shared.so.100` and friends don't exist. `--static` seems to do the trick in that the compiled file is no

Re: Hipreme's #2 Tip of the day - Reducing .di files dependency

2022-10-25 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 23 October 2022 at 20:12:46 UTC, Hipreme wrote: This will greatly reduce the number of import and dependencies you need if you ever need to distribute a library. Could you elaborate more on the benefit? Does it reduce compilation time for dependency? If so then how much?

Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Andrey Zherikov via Digitalmars-d-learn
I have the following types (simplified version of my code): ```d struct A { int[] i; } struct B { A[] a = [A.init]; } ``` This code: ```d auto b1 = B.init; b1.a[0].i ~= 1; b1.a ~= A.init; b1.a[0].i ~= 11; b1.a[1].i ~= 12; b1.writeln; auto b2 = B();

Re: Static executable (ldc, linux)

2022-10-25 Thread Kagamin via Digitalmars-d-learn
ldc2 -link-defaultlib-shared=false or something like that

Re: Static executable (ldc, linux)

2022-10-25 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 10:55:33 UTC, Kagamin wrote: ldc2 -link-defaultlib-shared=false or something like that Thanks.

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 14:53:50 UTC, Adam D Ruppe wrote: But just don't do this. Only basic values and immutable strings are good to initialize this way. With the array or class objects, you're liable to get some shared thing. If you change this to be initialized in a constructor

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov wrote: A[] a = [A.init]; This is a problem - this is referring to a static array instance, shared across all copies of B. You almost certainly don't want this. That B.a[0] is the *same object* across different

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 07:53, Adam D Ruppe wrote: > On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov wrote: >> A[] a = [A.init]; > > This is a problem - this is referring to a static array instance, shared > across all copies of B. You almost certainly don't want this. Agreed. It should be

Re: Disabling All Inlining in DMD Debug Builds

2022-10-25 Thread ryuukk_ via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 08:14:26 UTC, Per Nordlöw wrote: On Monday, 24 October 2022 at 20:43:45 UTC, ryuukk_ wrote: I wish we could do ``version(DebugFast | Release)`` Moreover, I've been using, for instance, ```d version(D_Coverage) {} else pragma(inline, true); void foo() {} ``` to

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 14:53:50 UTC, Adam D Ruppe wrote: On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov wrote: A[] a = [A.init]; This is a problem - this is referring to a static array instance, shared across all copies of B. You almost certainly don't want this.

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 08:50, Andrey Zherikov wrote: > I'd like to tune default ctor but structs can't have custom one. > Adding a ctor with parameter seems a hack to me There is static opCall, which may be seen as a hack as well. :) The following all print the same thing now: import std.stdio; struct

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 17:18:35 UTC, Paul Backus wrote: It's not a bug. They're pointing to the exact same instance of `A` in memory: I don't understand? So I don't understand why it causes problems with dynamic arrays! So why is there nothing wrong with the static array in the

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 11:01, Ali Çehreli wrote: > static arrays don't have .ptr to point > to any member. Why do I say incorrect things like that? :) Of course static arrays have .ptr as well but that always point to their own body of N elements. They own their elements... I move away from the keyboard

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov wrote: Does the second piece of code shows a bug or my expectation is not correct (and why if so)? This is a bug: ```d void main() { struct B { struct A { int i = 10; } A[] a = [A.init]; } B[2] b;

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 16:52:48 UTC, Salih Dincer wrote: On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov wrote: Does the second piece of code shows a bug or my expectation is not correct (and why if so)? This is a bug: ```d void main() { struct B { struct A {

Re: Disabling All Inlining in DMD Debug Builds

2022-10-25 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 08:14:26 UTC, Per Nordlöw wrote: On Monday, 24 October 2022 at 20:43:45 UTC, ryuukk_ wrote: I wish we could do ``version(DebugFast | Release)`` Moreover, I've been using, for instance, ```d version(D_Coverage) {} else pragma(inline, true); void foo() {} ``` to

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/22 2:03 PM, Ali Çehreli wrote: On 10/25/22 11:01, Ali Çehreli wrote: > static arrays don't have .ptr to point > to any member. Why do I say incorrect things like that? :) Of course static arrays have .ptr as well but that always point to their own body of N elements. They own

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 10:54, Salih Dincer wrote: > So I don't understand why it causes problems with > dynamic arrays! So why is there nothing wrong with the static array in > the example below? The same rules as other uses of dynamic arrays... > //A[] a = [A.init];/* In that case, there is a

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 26 October 2022 at 00:44:45 UTC, H. S. Teoh wrote: If you'll excuse some ASCII art, here's the situation you have: STACK GLOBAL DATA x[0] { Y[] y; -+> [ Y.init ] } | x[1] { |

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 20:36:28 UTC, matheus wrote: On int[] a = [1]; int[] b = a.dup; assert([0] !is [0]); // different memory ``` This is interesting, I understand the point of "reference vs copy", and I'm OK with this design choice of, but I wonder in the case of newcomers if

Re: Replacing tango.text.Ascii.isearch

2022-10-25 Thread Siarhei Siamashka via Digitalmars-d-learn
On Wednesday, 26 October 2022 at 05:17:06 UTC, rikki cattermole wrote: if you are able to ignore that Unicode is a thing, I'd recommend it. It is complicated, as we humans are very complicated ;) I can't ignore Unicode, because I frequently have to deal with Cyrillic alphabet ;) Also Unicode

Re: auto scope question?

2022-10-25 Thread WhatMeWorry via Digitalmars-d-learn
typeof(screen.output.findSplit("")) s; Perfect. That was the "essence" of my question. But thanks to Ali, I don't have to use such esoteric syntax. D is a wonderful language, but I seem to shoot myself in the foot :)

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 19:25, Salih Dincer wrote: > with static in main(): If 'static' makes a difference on your side as well, it is your turn to create a bug report. :) (Last time you discovered a bug, I was too quick to report it. :/) Ali

Re: auto scope question?

2022-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/22 6:07 PM, WhatMeWorry wrote: I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code?  I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... {     s =

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 26 October 2022 at 02:34:24 UTC, Ali Çehreli wrote: On 10/25/22 19:25, Salih Dincer wrote: > with static in main(): If 'static' makes a difference on your side as well, it is your turn to create a bug report. :) (Last time you discovered a bug, I was too quick to report it. :/)

Re: Replacing tango.text.Ascii.isearch

2022-10-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2022 6:06 PM, Siarhei Siamashka wrote: Should we ignore the `"D should strive to be correct, rather than fast"` comment from bauss for now? Or some actions can be taken to improve the current situation? Bauss is correct. It should be implemented but it does not need to be fast. But

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 26, 2022 at 12:16:55AM +, Salih Dincer via Digitalmars-d-learn wrote: [...] > I've known D for more than 10 years, but the topic we're talking about > still seems strange to me. The explanations given are not enough for > me, I'm sorry. > > Can anyone tell me what happens when I

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 17:16, Salih Dincer wrote: > Excuse me, but they still write in purple prose about dynamic > array literature here! I've heard positive things about D's arrays from people who use D in production. Especially slices... > I've known D for more than 10 years, but the topic we're

Re: Replacing tango.text.Ascii.isearch

2022-10-25 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 06:32:00 UTC, rikki cattermole wrote: On 25/10/2022 5:17 PM, Siarhei Siamashka wrote: What are the best practices to deal with Turkish text in D language? std.uni doesn't support it. OK, I'm not specifically interested in this personally and I even would be

auto scope question?

2022-10-25 Thread WhatMeWorry via Digitalmars-d-learn
I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code? I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... { s = screen.output.findSplit("REG_SZ"); } but that doesn't compile

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 13:36, matheus wrote: > On Tuesday, 25 October 2022 at 20:12:25 UTC, Paul Backus wrote: >> Static arrays are value types. What that means is, when we say float[3], there are just 3 floats without any overhead. >> Dynamic arrays are reference types. That phrase can be confusing

Re: auto scope question?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 15:07, WhatMeWorry wrote: > auto screen = executeShell(cmdLine); > auto s; That can't work because there is no information to infer the type of 's'. Judging from the return type of getPath, perhaps it's string[]: string[] s; This is the question we should answer first: What

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 13:12, Paul Backus wrote: > In order to create a copy of a static array Although .dup works for static arrays as well, you meant "dynamic array" and everyones knows it. :) > with its own block of > memory, separate from the original, you have to use the built-in `.dup` > method:

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread matheus via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 20:12:25 UTC, Paul Backus wrote: On Tuesday, 25 October 2022 at 17:54:16 UTC, Salih Dincer wrote: On Tuesday, 25 October 2022 at 17:18:35 UTC, Paul Backus wrote: It's not a bug. They're pointing to the exact same instance of `A` in memory: I don't understand?

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 20:27:18 UTC, Ali Çehreli wrote: On 10/25/22 13:12, Paul Backus wrote: > In order to create a copy of a static array Although .dup works for static arrays as well, you meant "dynamic array" and everyones knows it. :) Yes; thank you for the correction. :)

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 17:54:16 UTC, Salih Dincer wrote: On Tuesday, 25 October 2022 at 17:18:35 UTC, Paul Backus wrote: It's not a bug. They're pointing to the exact same instance of `A` in memory: I don't understand? So I don't understand why it causes problems with dynamic

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 11:23, Steven Schveighoffer wrote: >> Why do I say incorrect things like that? :) > You were right actually. As always! Now I'm confused. :o) Ali