Re: alias Error: need 'this'

2023-03-19 Thread bomat via Digitalmars-d-learn
On Sunday, 19 March 2023 at 12:29:19 UTC, Salih Dincer wrote: It is possible to achieve the convenience you want to achieve in 2 ways. One of them is to use a static member but if not, to use an alias inside the container. Thanks for the suggested workaround, I can live with the `static`

alias Error: need 'this'

2023-03-19 Thread bomat via Digitalmars-d-learn
Hi, I read about aliases today and thought it would be handy for shortening repeated access to struct members. However, I'm clearly missing something. Here's some example code: ``` int variableWithALongName = 42; alias alias1 = variableWithALongName; alias1 = 43; assert(variableWithALongName

Re: #define-like behavior

2023-03-15 Thread bomat via Digitalmars-d-learn
Just out of curiosity: Can you explain to me why this is called an `enum` although it's clearly not an enumeration? Seems like a random abuse of a keyword...

Re: #define-like behavior

2023-03-15 Thread bomat via Digitalmars-d-learn
On Wednesday, 15 March 2023 at 19:27:19 UTC, Paul Backus wrote: It's shorthand for defining an unnamed `enum` with a single member: ... Ah, I see. Thanks!

Re: @nogc and Phobos

2023-03-14 Thread bomat via Digitalmars-d-learn
On Saturday, 11 March 2023 at 22:14:36 UTC, rempas wrote: The `foreach` will cover your needs like you said but ironically enough, I like and use the original `for` loop. Thanks for your reply as well, rempas... I guess I covered most things in my earlier reply, but on the `for` loop: Coming

Re: @nogc and Phobos

2023-03-14 Thread bomat via Digitalmars-d-learn
Thanks a lot for taking the time and replying in that much detail! On Saturday, 11 March 2023 at 21:07:18 UTC, H. S. Teoh wrote: I also came from a C/C++ background. The GC turned me off D for a long time, until one day I decided to just give it a try to see if it was all as bad as people

@nogc and Phobos

2023-03-11 Thread bomat via Digitalmars-d-learn
Hi all, I am a C++ programmer in my "day job" and was playing around with D to maybe use it in a personal project. I'm using Dear ImGui for the graphical user interface, for which I use this port: https://github.com/KytoDragon/imgui/ It works fairly well so far, just one problem: Dear

Re: @nogc and Phobos

2023-03-11 Thread bomat via Digitalmars-d-learn
Thanks for the responses everyone, that was all very helpful and got me on the right track. Especially this: On Saturday, 11 March 2023 at 14:41:01 UTC, Steven Schveighoffer wrote: I think it is an error to mark a library which centers on callbacks with always being @nogc. You can work around

Re: @nogc and Phobos

2023-03-11 Thread bomat via Digitalmars-d-learn
On Saturday, 11 March 2023 at 13:18:13 UTC, rempas wrote: Even if the first was the case (which again, only things that need the GC will not be able to be used), D is far from been "useless". You can use `betterC` and use C's libraries. Personally, that's what I'm doing anyway. Even if there

Re: vibe-d REST API: POSTing a struct

2023-12-17 Thread bomat via Digitalmars-d-learn
On Friday, 15 December 2023 at 07:36:04 UTC, aj_dlang wrote: does it active? If you mean if that vibe-d forum is still active, I don't know. I tried to register, but I never got a confirmation mail... so probably not. On the other hand, there wasn't a response to my question on this board

Re: D is nice whats really wrong with gc??

2023-12-22 Thread bomat via Digitalmars-d-learn
On Monday, 18 December 2023 at 16:44:11 UTC, Bkoie wrote: but what is with these ppl and the gc? [...] I'm a C++ programmer in my day job. Personally, I have no problem with a GC, but one of my colleague is a total C fanboy, so I feel qualified to answer your question. :) I think the

Re: D is nice whats really wrong with gc??

2023-12-22 Thread bomat via Digitalmars-d-learn
On Friday, 22 December 2023 at 16:51:11 UTC, bachmeier wrote: Given how fast computers are today, the folks that focus on memory and optimizing for performance might want to apply for jobs as flooring inspectors, because they're often solving problems from the 1990s. *Generally* speaking, I

Re: D is nice whats really wrong with gc??

2023-12-23 Thread bomat via Digitalmars-d-learn
On Friday, 22 December 2023 at 22:33:35 UTC, H. S. Teoh wrote: IMNSHO, if I had very large data files to load, I wouldn't use JSON. Precompile the data into a more compact binary form that's already ready to use, and just mmap() it at runtime. I wondered about that decision as well,

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-13 Thread bomat via Digitalmars-d-learn
I am still getting this in 2024 and vibe.d 0.9.7: ``` Warning: 1 socket handles leaked at driver shutdown. ``` I was wondering if maybe someone has new info on this...

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-16 Thread bomat via Digitalmars-d-learn
On Monday, 15 January 2024 at 22:19:56 UTC, Steven Schveighoffer wrote: You may have to do the same thing I did with redis: https://github.com/vibe-d/vibe.d/pull/2372 Good luck! I would also say, I don't know why Windows doesn't do the same trace info debug thing, except that probably

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-15 Thread bomat via Digitalmars-d-learn
On Monday, 15 January 2024 at 17:45:16 UTC, Steven Schveighoffer wrote: Which driver are you using? In the posix driver, it should mention (and use) the debug flag `EventCoreLeakTrace`.

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-16 Thread bomat via Digitalmars-d-learn
Wow, that was... exhaustive. Thanks for that. :) One more question that I have, though... On Tuesday, 16 January 2024 at 19:05:43 UTC, Jonathan M Davis wrote: The downside of course is that you then have import statements throughout your code, and they're often going to be duplicated

Re: vibe-d REST API: POSTing a struct

2023-12-02 Thread bomat via Digitalmars-d-learn
On Friday, 1 December 2023 at 19:18:19 UTC, bomat wrote: So my question is, is it possible to have vibe-d parse the request body into a struct "implicitly"? I'm gonna answer my own question here, it's `@bodyParam`. https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/40001/

vibe-d REST API: POSTing a struct

2023-12-01 Thread bomat via Digitalmars-d-learn
Hey everyone, I'm looking into vibe-d, particularly how to build a REST API server. Given this struct: ``` struct Project { string project_id; string name; } ``` I could write a GETter like this: ``` @path("projects/:project_id") Project getProject(string _project_id); ``` and a POST

Re: struct initializer

2023-12-01 Thread bomat via Digitalmars-d-learn
I completely agree with the OP, and I want to illustrate this by another example which I find quite bizarre: ``` struct S { int a; int b; } S[] s_list = new S[0]; // this works S s = { a:1, b:2 }; s_list ~= s; // this does not s_list ~= { a:1, b:2 }; ``` I'm a C++ programmer in my day job

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-15 Thread bomat via Digitalmars-d-learn
On Sunday, 14 January 2024 at 20:36:44 UTC, Steven Schveighoffer wrote: There should be a version you can enable that tells you where that socket handle was allocated. That might give you a further clue as to why it's not closed when the system shuts down. I think the program tells you which