August 18
On 18/08/2024 7:49 AM, Vinod K Chandran wrote:
> On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer wrote:
>>
>> Go to dlang.org, select dicumentation, then library reference.
>>
>> Pick any module, click on it
>>
>> In the upper right, switch the docs from stable to ddox
>>
>> Now you can use the search bar and it is interactive. Typing in indexOf found it right away.
>>
> 
> Steve, We need a better search system. For example, I needed something like the `thread.sleep()` in .net today. All I want is a delay function which simulate some work load in current thread. But sadly, it is difficult to find.
> -kcvinker

https://dlang.org/phobos/core_thread_osthread.html#.Thread.sleep

Worth noting is that sleeping is not equivalent to performing work. It's the exact opposite, the lack of work.

If you want to simulate work being done, use a loop with a stop watch to determine how much time has progressed.

August 18

On Saturday, 17 August 2024 at 19:49:04 UTC, Vinod K Chandran wrote:

>

All I want is a delay function which simulate some work load in current thread.

As Rikki points out, delay or sleep functions (as the name says) ‘put the thread to sleep’. If you want the thread to be constantly busy, you can use a while loop:

import core.time;

//waste electricity for 1ms:
const endTime = MonoTime.currTime + 1.msecs;
while(MonoTime.currTime < endTime){}

Note that it’s better to let the thread rest because otherwise the OS might be starved for threads, or the CPU will consume more electricity and could overheat unnecessarily, hindering your program’s performance.

August 18
On Saturday, 17 August 2024 at 19:54:07 UTC, Richard (Rikki) Andrew Cattermole wrote:
>
> https://dlang.org/phobos/core_thread_osthread.html#.Thread.sleep
>
> Worth noting is that sleeping is not equivalent to performing work. It's the exact opposite, the lack of work.
>

Thanks Rikki. Actually, I was checked `core.thread` page. But at the top, after a speedy search, unfprtunately, I couldn't find anything. Now, I can see that beneath first second `Jump to` section, there is a `sleep`.
>
> If you want to simulate work being done, use a loop with a stop watch to determine how much time has progressed.
>
Point noted. Thanks!



August 18

On Sunday, 18 August 2024 at 08:39:49 UTC, IchorDev wrote:

>

As Rikki points out, delay or sleep functions (as the name says) ‘put the thread to sleep’. If you want the thread to be constantly busy, you can use a while loop:

import core.time;

//waste electricity for 1ms:
const endTime = MonoTime.currTime + 1.msecs;
while(MonoTime.currTime < endTime){}

Note that it’s better to let the thread rest because otherwise the OS might be starved for threads, or the CPU will consume more electricity and could overheat unnecessarily, hindering your program’s performance.

Thank you IchorDev for the sample code. Got the idea.

August 19

On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer wrote:

>

Go to dlang.org, select dicumentation, then library reference.

Pick any module, click on it

In the upper right, switch the docs from stable to ddox

Now you can use the search bar and it is interactive. Typing in indexOf found it right away.

Good trick, Steve. I've been working/playing with D for almost six years and I didn't know that. Thank you.

August 19

On Monday, 19 August 2024 at 06:53:34 UTC, Ron Tarrant wrote:

>

On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer wrote:

>

Go to dlang.org, select dicumentation, then library reference.

Pick any module, click on it

In the upper right, switch the docs from stable to ddox

Now you can use the search bar and it is interactive. Typing in indexOf found it right away.

Good trick, Steve. I've been working/playing with D for almost six years and I didn't know that. Thank you.

OMG why is that not the default in that search box??? It's so much better with interactive search!

August 20

On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer wrote:

>

On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:

>

What is the best way to search for a function
in the Phobos library?

Go to dlang.org, select dicumentation, then library reference.

Pick any module, click on it

In the upper right, switch the docs from stable to ddox

Now you can use the search bar and it is interactive. Typing in indexOf found it right away.

I'm doing some network programming, and have run things down with casts and all to the point where I have an IPv4 address. The documentation says it's in "host order", so obviously a 32-bit number. My C days tell me htonl is what's needed--but it's nowhere to be found in the API index? I did a search and it's apparently under core/sys, but "sys" isn't included in the online documentation?

Doing bulk searches in /usr/lib/ldc/x86_64-linux-gnu/include/d/core/sys lets me run it down to three places, of which I'd guess posix/arpa/inet.d is the one to use.

But this all seems a little bit harder than it might be?

A map of C or Python API's to the Dlang counterpart might be the easiest way to let people find things.

August 21

On Tuesday, 20 August 2024 at 21:53:10 UTC, Andy Valencia wrote:

>

On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer wrote:

>

On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:

>

What is the best way to search for a function
in the Phobos library?

Go to dlang.org, select dicumentation, then library reference.

Pick any module, click on it

In the upper right, switch the docs from stable to ddox

Now you can use the search bar and it is interactive. Typing in indexOf found it right away.

I'm doing some network programming, and have run things down with casts and all to the point where I have an IPv4 address. The documentation says it's in "host order", so obviously a 32-bit number. My C days tell me htonl is what's needed--but it's nowhere to be found in the API index? I did a search and it's apparently under core/sys, but "sys" isn't included in the online documentation?

Doing bulk searches in /usr/lib/ldc/x86_64-linux-gnu/include/d/core/sys lets me run it down to three places, of which I'd guess posix/arpa/inet.d is the one to use.

But this all seems a little bit harder than it might be?

A map of C or Python API's to the Dlang counterpart might be the easiest way to let people find things.

core.sys is OS-specific API bindings. They have no documentation, and I can imagine that the sheer amount of version statements in them would break the documentation generation.

You should’ve probably considered using the equivalent function from Phobos because it’s a D function so it can be inlined and such:
https://dlang.org/library/std/bitmanip/native_to_big_endian.html

August 21

On Wednesday, 21 August 2024 at 20:45:10 UTC, IchorDev wrote:

>

You should’ve probably considered using the equivalent function from Phobos because it’s a D function so it can be inlined and such:
https://dlang.org/library/std/bitmanip/native_to_big_endian.html

Brilliant, that API gives me exactly what I'd want. Thank you.

Andy

August 21

On Wednesday, 21 August 2024 at 21:22:44 UTC, Andy Valencia wrote:

>

On Wednesday, 21 August 2024 at 20:45:10 UTC, IchorDev wrote:

>

You should’ve probably considered using the equivalent function from Phobos because it’s a D function so it can be inlined and such:
https://dlang.org/library/std/bitmanip/native_to_big_endian.html

Brilliant, that API gives me exactly what I'd want. Thank you.

Andy

No problem! :)

1 2
Next ›   Last »