Re: Template sequence parameter and default value

2022-01-26 Thread Jaime via Digitalmars-d-learn
On Thursday, 27 January 2022 at 02:49:22 UTC, Andrey Zherikov wrote: What is the best way to emulate a default value for template sequence parameter of a function? I want something like this: ```d void foo(MODULES... = __MODULE__)() {} // these should work: foo!(module1, module2);

Re: What is safe to do in an extern (C) function and how can I test this?

2022-01-24 Thread Jaime via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 01:41:03 UTC, Steven Schveighoffer wrote: On 1/24/22 8:31 PM, Jaime wrote: Can I, for instance, safely call Fiber.yield in a C callback that I know will be run in a Fiber? I would *imagine* it's fine, all the fiber context switch is doing (WRT the stack) is

What is safe to do in an extern (C) function and how can I test this?

2022-01-24 Thread Jaime via Digitalmars-d-learn
**The lede**: Can I, for instance, safely call Fiber.yield in a C callback that I know will be run in a Fiber? The stack will look like: Thread |- Fiber in D runtime | |- Call into a C API (stays on same thread) | | |- Extern (C) callback (stays on same thread) | | | |- Fiber.yield <-- Is

Re: Ensuring allocation isn't thread-local?

2022-01-22 Thread Jaime via Digitalmars-d-learn
On Saturday, 22 January 2022 at 19:06:38 UTC, Adam D Ruppe wrote: No. Anything allocated with `new` is not thread local... and even if it was, you can send the pointer to other threads anyway. The only things in thread local storage are the direct values in the non-shared global variables.

Ensuring allocation isn't thread-local?

2022-01-22 Thread Jaime via Digitalmars-d-learn
Howdy. How do I make sure data isn't allocated thread-local, if I also want to immediately use it in a thread-local way, because, for instance, I happen to already possess its intended mutex, which was allocated before it? Is this sufficient? Also, is it even something to worry about? ```d

Re: Unintuitive behavior with shared classes & template member functions; is this intended?

2022-01-16 Thread Jaime via Digitalmars-d-learn
On Saturday, 15 January 2022 at 02:52:20 UTC, Steven Schveighoffer wrote: you probably can fix the issue via: ```d class C { shared: ... // everything } ``` This seems like a good solution. To achieve implicit sharing on the aggregate itself, I can use this approach to define a

Unintuitive behavior with shared classes & template member functions; is this intended?

2022-01-14 Thread Jaime via Digitalmars-d-learn
Some code that produces the strange behavior I'm seeing: ```d shared class MyClass { this() {} this(As...)(As args) if (As.length > 0) {} } void main() { pragma(msg, typeof(new MyClass)); pragma(msg, typeof(new MyClass(1, 2, 3, "hello world"))); pragma(msg, typeof(new