Re: Struct initializer in UDA

2020-09-27 Thread realhet via Digitalmars-d-learn
On Sunday, 27 September 2020 at 11:59:49 UTC, Anonymouse wrote: On Sunday, 27 September 2020 at 10:17:39 UTC, realhet wrote: On Saturday, 26 September 2020 at 17:13:17 UTC, Anonymouse wrote: On Saturday, 26 September 2020 at 16:05:58 UTC, realhet wrote: That looks the closes to the python

Re: How to hide a function return type in order to wrap several functions into an associated array?

2020-09-27 Thread Ali Çehreli via Digitalmars-d-learn
On 9/27/20 11:54 AM, tastyminerals wrote: > I have a collection of functions that all have the same input, a string. > The output however is different and depending on what the function does > it can be ulong, double or bool. The following approach overcomes the different return type issue by

Re: conflicting alias in package module

2020-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/26/20 9:45 AM, Steven Schveighoffer wrote: On 9/26/20 3:33 AM, 60rntogo wrote: and this is an error: "struct pack.foo.Foo at source/pack/foo.d(3,1) conflicts with alias pack.bar.Foo at source/pack/bar.d(3,8)". I seems like the import in package.d sees Foo both in pack.foo and pack.bar,

Re: assert format of a string before a mixin

2020-09-27 Thread ddcovery via Digitalmars-d-learn
On Sunday, 27 September 2020 at 21:41:25 UTC, Adam D. Ruppe wrote: On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote: i.e. checking this Regex expression `^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$` Is there any way to check a regular expression at compile time? Not really

Re: assert format of a string before a mixin

2020-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote: i.e. checking this Regex expression `^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$` Is there any way to check a regular expression at compile time? Not really and I'd actually suggest not trying because even if it did work,

assert format of a string before a mixin

2020-09-27 Thread ddcovery via Digitalmars-d-learn
I have a "variation" of "unaryFun" that I name "unaryProp" that, basically, doesn't require to specify "a." at the beginning of the expression. template unaryProp(alias propName) { static assert(is(typeof(propName) : string), "Sorry, propName must be an string"); auto

Re: Safe to remove AA elements while iterating over it via .byKeyValue?

2020-09-27 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote: No. Modifying a container while iterating over it is, in general, a bad idea (unless the container is designed to be used that way, but even then, such removal is generally restricted), because it often leads to highly

Re: How to hide a function return type in order to wrap several functions into an associated array?

2020-09-27 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 27 September 2020 at 18:54:11 UTC, tastyminerals wrote: This is rather a generic implementation question not necessarily related to D but I'd like to get some opinions. I have a collection of functions that all have the same input, a string. The output however is different and

Re: conflicting alias in package module

2020-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/27/20 1:17 AM, 60rntogo wrote: On Sunday, 27 September 2020 at 03:33:20 UTC, Mike Parker wrote: package.d is for your external interface. Fair enough, thanks. This isn't an issue with package, it's an issue with a circular dependency. You are importing yourself and trying alias

Re: AA with class keys compared with identity instead of opEquals

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 27 September 2020 at 19:37:10 UTC, Per Nordlöw wrote: On Sunday, 27 September 2020 at 18:39:10 UTC, Per Nordlöw wrote: How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`? I got a good answer at

Re: AA with class keys compared with identity instead of opEquals

2020-09-27 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 27 September 2020 at 18:39:10 UTC, Per Nordlöw wrote: How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`? I got a good answer at https://dlang.slack.com/archives/C1ZDHBB2S/p1601234030016700

Re: AA with class keys compared with identity instead of opEquals

2020-09-27 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 27 September 2020 at 18:56:15 UTC, Ferhat Kurtulmuş wrote: By looking at object.d and aaA.d of druntime, I d say you don't need to use void*. Object class has required infrastructure ready for using classes aa keys (have not tried though). Object class has both toHash and opEquals

Re: Timeout around function call

2020-09-27 Thread drathier via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 20:58:00 UTC, Imperatorn wrote: On Wednesday, 23 September 2020 at 20:54:51 UTC, Imperatorn wrote: On Wednesday, 23 September 2020 at 20:44:51 UTC, Ali Çehreli wrote: On 9/23/20 1:19 PM, Imperatorn wrote: > [...] send a > [...] with timeout. [...] Sorry,

Re: AA with class keys compared with identity instead of opEquals

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 27 September 2020 at 18:39:10 UTC, Per Nordlöw wrote: How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`? By looking at object.d and aaA.d of druntime, I d say you don't need to use void*.

How to hide a function return type in order to wrap several functions into an associated array?

2020-09-27 Thread tastyminerals via Digitalmars-d-learn
This is rather a generic implementation question not necessarily related to D but I'd like to get some opinions. I have a collection of functions that all have the same input, a string. The output however is different and depending on what the function does it can be ulong, double or bool. The

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 27 September 2020 at 16:39:45 UTC, Ali Çehreli wrote: On 9/27/20 6:33 AM, Ferhat Kurtulmuş wrote: > [...] Kurtulmuş wrote: >> [...] wrote: > [...] processing > [...] How many flame threads do you need? I thought one image processor and one flame thrower, no? Even if you

AA with class keys compared with identity instead of opEquals

2020-09-27 Thread Per Nordlöw via Digitalmars-d-learn
How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`?

Re: I need "windowsx.d" Someone can send It to me?

2020-09-27 Thread Imperatorn via Digitalmars-d-learn
On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d I converting it using VisualD: https://pastebin.com/jzwKRnKZ Try it, maybe it works

Cmake dependency scanning

2020-09-27 Thread IGotD- via Digitalmars-d-learn
Do we have any D dependency scanning available for D in Cmake, just like the built in C/C++ dependency scanner which is handy, or do you have to use the option to compile everything into one module (--deps=full)? I have some problems when there is a mix of inlining and calling the separately

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ali Çehreli via Digitalmars-d-learn
On 9/27/20 6:33 AM, Ferhat Kurtulmuş wrote: > On Sunday, 27 September 2020 at 12:05:13 UTC, Ferhat Kurtulmuş wrote: >> On Sunday, 27 September 2020 at 10:40:25 UTC, Ali Çehreli wrote: >>> On 9/27/20 3:06 AM, Ferhat Kurtulmuş wrote: > > Oh, It will work fine if I imitate my time-consuming image

Re: Array Slicing

2020-09-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Sep 27, 2020 at 01:59:07PM +, DMon via Digitalmars-d-learn wrote: > Are these in the Specification or Phobos? See: https://dlang.org/articles/d-array-article.html T -- Государство делает вид, что платит нам зарплату, а мы делаем вид, что работаем.

Re: Safe to remove AA elements while iterating over it via .byKeyValue?

2020-09-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Sep 27, 2020 at 01:02:04PM +, Per Nordlöw via Digitalmars-d-learn wrote: > Is it safe to remove AA-elements from an `aa` I'm iterating over via > aa.byKeyValue? No. Modifying a container while iterating over it is, in general, a bad idea (unless the container is designed to be used

Re: Safe to remove AA elements while iterating over it via .byKeyValue?

2020-09-27 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote: Is it safe to remove AA-elements from an `aa` I'm iterating over via aa.byKeyValue? I'm currently doing this: foreach (ref kv; aa.byKeyValue) { if (pred(kv.key)) aa.remove(kv.key); // ok? } if

Array Slicing

2020-09-27 Thread DMon via Digitalmars-d-learn
Are these in the Specification or Phobos? I figured them out a few days ago. These are from my snippet journal on arrays and there may be more. void main() { int[5] a = [1, 2, 3, 4, 5]; int[5][3] b = [[6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]; int[5] c;

Re: Safe to remove AA elements while iterating over it via .byKeyValue?

2020-09-27 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote: Is it safe to remove AA-elements from an `aa` I'm iterating over via aa.byKeyValue? I'm currently doing this: foreach (ref kv; aa.byKeyValue) { if (pred(kv.key)) aa.remove(kv.key); // ok? } if

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 27 September 2020 at 12:05:13 UTC, Ferhat Kurtulmuş wrote: On Sunday, 27 September 2020 at 10:40:25 UTC, Ali Çehreli wrote: On 9/27/20 3:06 AM, Ferhat Kurtulmuş wrote: Oh, It will work fine if I imitate my time-consuming image processing like this. I think it is Ok now. import

Re: Safe to remove AA elements while iterating over it via .byKeyValue?

2020-09-27 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote: Is it safe to remove AA-elements from an `aa` I'm iterating over via aa.byKeyValue? I'm currently doing this: foreach (ref kv; aa.byKeyValue) { if (pred(kv.key)) aa.remove(kv.key); // ok? } if

Safe to remove AA elements while iterating over it via .byKeyValue?

2020-09-27 Thread Per Nordlöw via Digitalmars-d-learn
Is it safe to remove AA-elements from an `aa` I'm iterating over via aa.byKeyValue? I'm currently doing this: foreach (ref kv; aa.byKeyValue) { if (pred(kv.key)) aa.remove(kv.key); // ok? } if (aa.length == 0) aa = null; Is there a better way?

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 27 September 2020 at 10:40:25 UTC, Ali Çehreli wrote: On 9/27/20 3:06 AM, Ferhat Kurtulmuş wrote: > __gshared DList!Entry queue; > __gshared bool shouldRun = true; Have you considered passing messages with std.concurrency.send() and std.concurrency.receive() and friends? You

Re: Struct initializer in UDA

2020-09-27 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 27 September 2020 at 10:17:39 UTC, realhet wrote: On Saturday, 26 September 2020 at 17:13:17 UTC, Anonymouse wrote: On Saturday, 26 September 2020 at 16:05:58 UTC, realhet wrote: The closest I can get is @(S.init.c(9).f(42)) with use of opDispatch, which is easier to read but still

Re: A scheduled control signal with fibers?

2020-09-27 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 27 September 2020 at 10:52:58 UTC, Ferhat Kurtulmuş wrote: On Sunday, 27 September 2020 at 10:40:25 UTC, Ali Çehreli wrote: [...] [...] I remember that your book covers passing messages with send(). Probably I will rewrite it using that mechanism, you are right, I noticed that

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 27 September 2020 at 10:40:25 UTC, Ali Çehreli wrote: On 9/27/20 3:06 AM, Ferhat Kurtulmuş wrote: Have you considered passing messages with std.concurrency.send() and std.concurrency.receive() and friends? You wouldn't need 'queue' because all of your threads already have mail

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ali Çehreli via Digitalmars-d-learn
On 9/27/20 3:06 AM, Ferhat Kurtulmuş wrote: > __gshared DList!Entry queue; > __gshared bool shouldRun = true; Have you considered passing messages with std.concurrency.send() and std.concurrency.receive() and friends? You wouldn't need 'queue' because all of your threads already have mail

Re: Struct initializer in UDA

2020-09-27 Thread realhet via Digitalmars-d-learn
On Saturday, 26 September 2020 at 17:13:17 UTC, Anonymouse wrote: On Saturday, 26 September 2020 at 16:05:58 UTC, realhet wrote: The closest I can get is @(S.init.c(9).f(42)) with use of opDispatch, which is easier to read but still ugly. All I can get is that the - an identifier of a member

Re: A scheduled control signal with fibers?

2020-09-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 25 September 2020 at 13:37:09 UTC, Steven Schveighoffer wrote: Given the rate and the number of concurrent tasks, I'd say threads. -Steve Here is my testable and minimal code using 1 extra thread. Thank you all! import core.thread; import std.stdio; import std.concurrency;

Re: Methods for expanding class in another class/struct

2020-09-27 Thread IGotD- via Digitalmars-d-learn
On Saturday, 26 September 2020 at 11:30:23 UTC, k2aj wrote: It does work, the problem is that scoped returns a Voldemort type, so you have to use typeof(scoped!SomeClass(someConstructorArgs)) to declare a field. Gets really annoying when doing it with any class that doesn't have a

Re: I need "windowsx.d" Someone can send It to me?

2020-09-27 Thread Denis Feklushkin via Digitalmars-d-learn
On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d Maybe it is already available on code.dlang.org?

Re: I need "windowsx.d" Someone can send It to me?

2020-09-27 Thread Imperatorn via Digitalmars-d-learn
On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d https://wiki.dlang.org/Bindings#Binding_generators

Re: I need "windowsx.d" Someone can send It to me?

2020-09-27 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 27 September 2020 at 07:55:56 UTC, Imperatorn wrote: On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d You don't want to

Re: I need "windowsx.d" Someone can send It to me?

2020-09-27 Thread Imperatorn via Digitalmars-d-learn
On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d You don't want to just include it?