Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-12 Thread Kagamin via Digitalmars-d-learn

On Friday, 10 February 2023 at 21:52:02 UTC, ProtectAndHide wrote:

Well in Swift, there is no problem .. at all.

Why is it a problem in D then? (and I mean technically).


What about the increment operator `++` ?


Re: ddbc with Vibe-d

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/12/23 3:29 PM, Steve wrote:

In my case args will just be the body of the HTTPServerRequest which is 
JSON. How can I get that JSON and pass it to async() in a manner that 
ensures I get a worker thread?


I think it needs to be immutable if it's a reference.

-Steve


Re: How does the function 'iota' get its name?

2023-02-12 Thread Sergey via Digitalmars-d-learn
On Sunday, 12 February 2023 at 19:39:49 UTC, Steven Schveighoffer 
wrote:

On 2/12/23 2:17 PM, ccmywish wrote:

Hi, everyone!

I'm very new to D. I see a function called 
[iota](https://dlang.org/library/std/range/iota.html)


`Iota` seems a [Greek 
letter](https://en.wikipedia.org/wiki/Iota). Why does it 
relate to range?


It came from C++. See notes here: 
https://en.cppreference.com/w/cpp/algorithm/iota


-Steve


Which took it from APL
https://aplwiki.com/wiki/Index_Generator


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 vibe's fibers to deal with the 
asynchronicity).


If it is possible, it will run in a worker thread, and then it 
can execute concurrently.


I believe you can do:

isWeaklyIsolated!(typeof(args))

to see if it will run in another thread.

I admit not having any experience with this function.

-Steve


In my case args will just be the body of the HTTPServerRequest 
which is JSON. How can I get that JSON and pass it to async() in 
a manner that ensures I get a worker thread?


Re: How does the function 'iota' get its name?

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/12/23 2:17 PM, ccmywish wrote:

Hi, everyone!

I'm very new to D. I see a function called 
[iota](https://dlang.org/library/std/range/iota.html)


`Iota` seems a [Greek letter](https://en.wikipedia.org/wiki/Iota). Why 
does it relate to range?


It came from C++. See notes here: 
https://en.cppreference.com/w/cpp/algorithm/iota


-Steve


Re: Gneric linkedList range adaptor

2023-02-12 Thread Ben Jones via Digitalmars-d-learn
On Saturday, 11 February 2023 at 05:02:49 UTC, Steven 
Schveighoffer wrote:




Reported

https://issues.dlang.org/show_bug.cgi?id=23687


Assuming this is a compiler bug and it gets fixed, does this seem 
like something worth trying to add to std.range?




Re: ddbc with Vibe-d

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/12/23 1:01 PM, Steve wrote:

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 that completes.





Would this be the correct approach to stop it blocking?:
```d
auto result = async(&doSqliteStuff, args...).getResult();
```


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 vibe's fibers to deal with the asynchronicity).


If it is possible, it will run in a worker thread, and then it can 
execute concurrently.


I believe you can do:

isWeaklyIsolated!(typeof(args))

to see if it will run in another thread.

I admit not having any experience with this function.

-Steve


How does the function 'iota' get its name?

2023-02-12 Thread ccmywish via Digitalmars-d-learn

Hi, everyone!

I'm very new to D. I see a function called 
[iota](https://dlang.org/library/std/range/iota.html)


`Iota` seems a [Greek 
letter](https://en.wikipedia.org/wiki/Iota). Why does it relate 
to range?


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 that completes.





Would this be the correct approach to stop it blocking?:
```d
auto result = async(&doSqliteStuff, args...).getResult();
```


Re: ddbc with Vibe-d

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/12/23 6:05 AM, Steve wrote:

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?


Thanks.


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 that completes.


There are several projects that are built to work with vibe-d sockets. 
mysql-native is one, and vibe-d-postgresql is another.


I don't know if there is an sqlite project that is vibe-specific. But 
sqlite typically is using files anyway, or maybe even memory, so you 
aren't waiting on network i/o.


-Steve


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?


Thanks.