ddbc with Vibe-d

2023-02-12 Thread Steve via Digitalmars-d-learn
Hi, I'm trying D for the first time and so far I'm really impressed with both D and vibe-d. My test project is an application server and I want to use SQLite3 as its database. I understand Vibe.d uses an async model under the hood and so my question is are Vibe-d and ddbc compatible? Than

Re: ddbc with Vibe-d

2023-02-12 Thread Steve via Digitalmars-d-learn
On Sunday, 12 February 2023 at 15:24:14 UTC, Steven Schveighoffer wrote: Any synchronous calls will just be synchronous. They aren't going to participate in the async i/o that vibe uses. In other words, when you block on a call to sqlite, it will block everything else in your web server until

Re: ddbc with Vibe-d

2023-02-12 Thread Steve via Digitalmars-d-learn
On Sunday, 12 February 2023 at 19:38:47 UTC, Steven Schveighoffer wrote: That might work, depending on args. As documented in the API, if anything in args are mutable references, then it is run as a task, and the same problem still applies (it will use a fiber, and count on the concurrency of v

Re: ddbc with Vibe-d

2023-02-13 Thread Steve via Digitalmars-d-learn
On Monday, 13 February 2023 at 01:43:38 UTC, Steven Schveighoffer wrote: I think it needs to be immutable if it's a reference. -Steve I have tested args with isWeaklyIsolated!(typeof(arg)) and it looks like good news 👍️ Thanks for your help, Steve.

My vibe-d test app is crashing on Windows

2023-02-13 Thread Steve via Digitalmars-d-learn
The app is just a test echo server. JSON sent in the body of a POST request is echoed back to the client. On Pop!_OS it works fine but on Windows it responds, there's a delay of about 10 seconds and then it crashes with the error: ``` Error Program exited with code -1073741819 ``` Here's the

Differences between lambda function and regular functions in higher order functions

2022-02-21 Thread steve via Digitalmars-d-learn
I am trying to implement a simple map function. I found code to do this in another post but it only seems to work with lambda functions and I do not understand why. Any help would be greatly appreciated ``` import std.stdio; T[] map_vals(T,S)(scope T function(S) f, S[] a){ auto b = new T[

Re: Differences between lambda function and regular functions in higher order functions

2022-02-21 Thread steve via Digitalmars-d-learn
thanks a lot both! Yes I'm aware that map exists already. This was didactic. I had tried to find out whether lambdas generate function pointers but also couldn't figure that one out :D

how to return map(fn)

2022-02-21 Thread steve via Digitalmars-d-learn
following this example in the documentation of map: ``` import std.algorithm.comparison : equal; import std.conv : to; alias stringize = map!(to!string); assert(equal(stringize([ 1, 2, 3, 4 ]), [ "1", "2", "3", "4" ])); ``` I would like to write a function that takes as its parameter a functi

Re: how to return map(fn)

2022-02-22 Thread steve via Digitalmars-d-learn
On Monday, 21 February 2022 at 23:07:44 UTC, Ali Çehreli wrote: On 2/21/22 12:44, steve wrote: ... thanks for your help. I'm unfortunately still a bit confused. Maybe I wasn't clear or maybe I'm just missing something here. What I was trying to return is function that can then be applied to

Re: how to return map(fn)

2022-02-23 Thread steve via Digitalmars-d-learn
Thank you both a lot for your help. I am new to D so all of this is incredibly helpful. This seems like an amazing community! @Ali I will have a look at std.functional as I think this is really what I was looking for. Until then, I have solved the problem with a simple class (e.g. below). I'm

Re: how to return map(fn)

2022-02-24 Thread steve via Digitalmars-d-learn
float times_two(float x) {return 2*x;} // if you would rather make sure the result is an array float[] times_two_array(float[] arr) { import std.algorithm; // for map import std.array; // for array return arr .map!times_two // map your function .array; // convert to an array