Re: Placement new and @trusted

2025-09-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 11/09/2025 12:29 AM, IchorDev wrote: I thought the 'placement new' feature might replace my need for `emplace`, but I don't see a way to mark a placement new as `@trusted` without marking the call to the object's constructor as `@trusted` also? ```d void main() @safe{ X x; //pla

Debug help - opDispatch - unknown member function

2025-09-11 Thread Brother Bill via Digitalmars-d-learn
https://tour.dlang.org/tour/en/gems/opdispatch-opapply This states: "Any unknown member function call to that type is passed to opDispatch, passing the unknown member function's name as a string template parameter." So I tried that. But the compiler didn't like it. How should I play the game

Re: Debug help - opDispatch - unknown member function

2025-09-11 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 11:57:54 UTC, Brother Bill wrote: On Tuesday, 9 September 2025 at 01:24:59 UTC, monkyyy wrote: ``` // I suggest a habit of avoiding simple names when generating mixin code ``` Please provide an example where providing simple names causes 'trouble'. ```d im

Re: Microsoft chose Go instead of C# or Rust to rewrite TypeScript

2025-09-11 Thread Kapendev via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 21:08:59 UTC, drug007 wrote: On 09.09.2025 01:53, Kapendev wrote: On Monday, 8 September 2025 at 21:25:25 UTC, drug007 wrote: On 08.09.2025 22:55, Neto wrote: On Monday, 8 September 2025 at 16:51:09 UTC, Serg Gini wrote: And not sure if ecosystem was a signifi

Re: Declaring a single const: enum vs const vs immutable

2025-09-11 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 10, 2025 at 05:15:16PM +, monkyyy via Digitalmars-d-learn wrote: [...] > I just do always enum; going all in on compile time abstractions Be careful, this may not always be what you want. For example: ```d enum data = [ 1, 2, 3 ]; void main() { auto buffer = data; //

Re: Debug help - opDispatch - unknown member function

2025-09-11 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 20:56:19 UTC, Steven Schveighoffer wrote: On Tuesday, 9 September 2025 at 20:08:06 UTC, monkyyy wrote: On Tuesday, 9 September 2025 at 19:17:11 UTC, Steven Schveighoffer wrote: In short `opDispatch` only is valid if it compiles. If it doesn't compile, it's as i

Re: Microsoft chose Go instead of C# or Rust to rewrite TypeScript

2025-09-11 Thread Serg Gini via Digitalmars-d-learn
On Wednesday, 10 September 2025 at 03:46:37 UTC, felixfxu wrote: On Monday, 8 September 2025 at 20:10:52 UTC, Sergey wrote: being focused on required important tasks = complicated I don't quite understand the item above. What's dlang's `"required important tasks"` now? This one actually ove

Re: Placement new and @trusted

2025-09-11 Thread Dennis via Digitalmars-d-learn
On Wednesday, 10 September 2025 at 12:29:24 UTC, IchorDev wrote: If anyone has any ideas, please let me know. The trick that's used in druntime is putting the part that still needs to be checked for attributes inside an `if (false)` block, for example: https://github.com/dlang/dmd/blob/c817

Re: help for example with Condition

2025-09-11 Thread Mikhail via Digitalmars-d-learn
On Thursday, 11 September 2025 at 09:51:55 UTC, Mikhail wrote: On Thursday, 11 September 2025 at 09:40:22 UTC, novicetoo wrote: cond and mutex are global variables, and "Starting with dmd version 2.030, the default storage class for statics and globals will be thread local storage (TLS)" http

Re: help for example with Condition

2025-09-11 Thread Mikhail via Digitalmars-d-learn
On Thursday, 11 September 2025 at 09:40:22 UTC, novicetoo wrote: cond and mutex are global variables, and "Starting with dmd version 2.030, the default storage class for statics and globals will be thread local storage (TLS)" https://dlang.org/articles/migrate-to-shared.html I don't understan

Re: help for example with Condition

2025-09-11 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 11 September 2025 at 09:29:29 UTC, Mikhail wrote: I wrote simple example to learn how the work Conditions. But program closed with signal, what's wrong? import std.stdio; import core.thread; import core.sync.condition; import core.sync.mutex; Condition cond; Mutex mutex; void thr

help for example with Condition

2025-09-11 Thread Mikhail via Digitalmars-d-learn
I wrote simple example to learn how the work Conditions. But program closed with signal, what's wrong? import std.stdio; import core.thread; import core.sync.condition; import core.sync.mutex; Condition cond; Mutex mutex; void threadFunction() { writeln("This is running in a separate threa

Re: Declaring a single const: enum vs const vs immutable

2025-09-11 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 10 September 2025 at 17:33:48 UTC, H. S. Teoh wrote: `enum` defines a compile-time constant. It occupies no space, and its value is "copied" into every expression in which it appears. [...] `const` and `immutable` are type qualifiers, and declaring a constant with them creates a

Re: Placement new and @trusted

2025-09-11 Thread IchorDev via Digitalmars-d-learn
On Thursday, 11 September 2025 at 03:47:02 UTC, Richard (Rikki) Andrew Cattermole wrote: It did go through the DIP process. Blast, you're right. I've even seen the DIP Development post for it before, too! I didn't read into it at the time. I could've probably identified this problem and raise

Re: Placement new and @trusted

2025-09-11 Thread IchorDev via Digitalmars-d-learn
On Thursday, 11 September 2025 at 04:19:02 UTC, Paul Backus wrote: The problem is not really with placement new, it's with constructors. Constructors are allowed to mutate immutable objects (under the assumption that they are initializing a newly-created object). If you call a constructor twice