Re: Function's local variables allocated on the heap.

2025-08-31 Thread realhet via Digitalmars-d-learn
On Sunday, 31 August 2025 at 22:11:26 UTC, Ali Çehreli wrote: On 8/31/25 2:36 PM, realhet wrote: ...long-term lifetime... Very cool feature. Even a function body can be used to make a composition of multiple objects. It acts like a class constructor, but with cleaner, simpler syntax, and auto

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Andy Valencia via Digitalmars-d-learn
On Sunday, 31 August 2025 at 22:53:51 UTC, Steven Schveighoffer wrote: `std.concurrency` is meant to make all these control flow systems easy to avoid races for, even in `@safe` code. Sending the boolean instead of keeping a pointer to a shared boolean can alleviate a lot of these problems.

Re: Function's local variables allocated on the heap.

2025-08-31 Thread Ali Çehreli via Digitalmars-d-learn
On 8/31/25 2:36 PM, realhet wrote: > Hi, > > I noticed that the local area of the myUi() function was allocated on > the heap, not on the stack as it would be the usual case with functions. Unless that's an optimization, that part would be the same: on the stack. However, because the delegate ne

Re: inside out iterating

2025-08-31 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 26 August 2025 at 20:04:36 UTC, monkyyy wrote: does anyone how a concept for insideout iterating I have this: ```d struct cursor(T){ T[] data; alias data this; int index; ref opIndex(int i){ return data[min($-1,max(0,i+index))]; } auto forward(){ s

Function's local variables allocated on the heap.

2025-08-31 Thread realhet via Digitalmars-d-learn
Hi, I noticed that the local area of the myUi() function was allocated on the heap, not on the stack as it would be the usual case with functions. Please explain me how the D compiler detects that. Does it knows that the myUi() function returns something, that contains a delegate which is ref

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 31 August 2025 at 12:44:33 UTC, Brother Bill wrote: On Sunday, 31 August 2025 at 01:27:57 UTC, Steven Schveighoffer wrote: Why would your second iteration make a difference? Purely by chance! In fact, on my machine, it does not exit in either case. Welcome to the wonderful world of

Re: is vs ==

2025-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Aug 30, 2025 at 10:15:26PM +, Brother Bill via Digitalmars-d-learn wrote: > For the modern D developer, which is the more preferred choice, to use > 'is' or '=='? [...] They have two different meanings. `is` is for determining identity (is this the same variable); whereas `==` is for

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Andy Valencia via Digitalmars-d-learn
On Sunday, 31 August 2025 at 12:44:33 UTC, Brother Bill wrote: FWIW, given that D supports Message Passing Concurrency, is Data Sharing Concurrency just there for D completeness, for those that want to live close to the iron. Speaking as a guy who did Unix kernel SMP for years, there are time

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Brother Bill via Digitalmars-d-learn
On Sunday, 31 August 2025 at 01:27:57 UTC, Steven Schveighoffer wrote: Why would your second iteration make a difference? Purely by chance! In fact, on my machine, it does not exit in either case. Welcome to the wonderful world of race conditions and multithreading! So this was just 'bad' lu

Re: Is D painted into a corner?

2025-08-31 Thread Brother Bill via Digitalmars-d-learn
On Thursday, 28 August 2025 at 21:51:23 UTC, monkyyy wrote: On Thursday, 28 August 2025 at 21:33:27 UTC, Brother Bill wrote: The 'old book' pdf seems to be the most current approach, and it should only be about 3 years old. Its not even close to only 3 years old, it mayve been updated some

Re: What's the use of 'typeof','typeid','__traits','is' ?

2025-08-31 Thread IchorDev via Digitalmars-d-learn
On Sunday, 24 August 2025 at 03:13:38 UTC, David T. Oxygen wrote: The code above has simplified. It defines some simple classes. And now, I have a function: ```d import std.algorithm.searching; MyReal is_int_or_float(string inputs){ if(inputs.canFind('.')) return new MyFloat(inputs);

Re: How to "dispose of" a string when using @live analysis?

2025-08-31 Thread IchorDev via Digitalmars-d-learn
On Saturday, 30 August 2025 at 21:00:11 UTC, Dukc wrote: Functions like `free` or `leak` take the parameter as non-`scope`, making sure you call them once and only once per variable you have allocated. It really should not require this for memory that is GC-allocated. How would you even free

Re: is vs ==

2025-08-31 Thread IchorDev via Digitalmars-d-learn
On Saturday, 30 August 2025 at 22:15:26 UTC, Brother Bill wrote: Do the Style Guidelines or other authorities prefer one to the other for modern D coding? No: https://dlang.org/dstyle.html For the modern D developer, which is the more preferred choice, to use 'is' or '=='? This question doe

Re: How to have multiple synchronized shared types. Programming in D, page 647

2025-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 31 August 2025 at 03:45:07 UTC, Ali Çehreli wrote: On 8/30/25 6:34 PM, Steven Schveighoffer wrote: > The original feature never worked as intended. That section of the book > should be removed. > > The correct way to do this is a nested synchronized statement: > > ```d > synchronized(