Re: How to correctly generate enums at compile time.

2017-04-30 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 30 April 2017 at 21:31:22 UTC, jkpl wrote: On Sunday, 30 April 2017 at 21:13:07 UTC, Kevin Balbas wrote: On Sunday, 30 April 2017 at 20:58:36 UTC, jkpl wrote: On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote: Strangely enough, it does work fine in the test snippet, As

Re: How to correctly generate enums at compile time.

2017-04-30 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 30 April 2017 at 20:58:36 UTC, jkpl wrote: On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote: I've got the following code snippet, which almost does what I want. struct TaggedType {} @TaggedType struct Foo {} @TaggedType struct Bar {} string GenerateTypeEnum() {

How to correctly generate enums at compile time.

2017-04-30 Thread Kevin Balbas via Digitalmars-d-learn
I've got the following code snippet, which almost does what I want. struct TaggedType {} @TaggedType struct Foo {} @TaggedType struct Bar {} string GenerateTypeEnum() { string enumString = "enum TypeEnum {"; foreach (name; __traits(allMembers, mixin(__MODULE__))) { import

Re: using shared effectively in a producer/consumer situation.

2017-04-23 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:30:33 UTC, Kevin Balbas wrote: I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this: void threadFunc(Tid

using shared effectively in a producer/consumer situation.

2017-04-23 Thread Kevin Balbas via Digitalmars-d-learn
I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this: void threadFunc(Tid ownerTid) { while(true) { receive(

Re: Trying to understand something about UDAs.

2016-12-12 Thread Kevin Balbas via Digitalmars-d-learn
On Monday, 12 December 2016 at 19:56:27 UTC, Adam D. Ruppe wrote: But the static if(is(UDA)) is probably what you actually want. That's exactly what I was looking for, thanks. I'm not sure I ever would've figured out that one on my own.

Trying to understand something about UDAs.

2016-12-12 Thread Kevin Balbas via Digitalmars-d-learn
I'm trying to figure out how to test whether a UDA struct was initialized with arguments (and change the behavior of the surrounding code if it was. While I was tinkering around with test files, I came up with this little gem: import std.traits; struct Attr { string str; }

Re: Calling arbitrary functions at runtime?

2016-12-11 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 11 December 2016 at 22:18:02 UTC, Adam D. Ruppe wrote: On Sunday, 11 December 2016 at 22:00:27 UTC, Kevin Balbas wrote: Basically, I need some way to turn an array of strings into an argument list at runtime. Is this possible? Write (or generate) a helper function that loops over

Calling arbitrary functions at runtime?

2016-12-11 Thread Kevin Balbas via Digitalmars-d-learn
I'm writing a system to register functions to be called at runtime. With zero-argument functions, it works fine. However, I run into a problem with functions that take arguments. This is the relevant code I started with (zero-argument version): mixin template CommandSystemRegister(string s