How to find the right function in the Phobos library?

IchorDev zxinsworld at gmail.com
Wed Aug 21 20:45:10 UTC 2024


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


More information about the Digitalmars-d-learn mailing list