Re: d strings are the bane of my existance

2021-12-06 Thread forkit via Digitalmars-d-learn
On Sunday, 5 December 2021 at 16:24:34 UTC, Chris Katko wrote: I know there "is" a solution, it's just so odd to have this much difficulty using a string. Paying attention to the online docs would help you too ;-) https://dlang.org/library/std/socket/internet_address.this.html But, in the

Re: d strings are the bane of my existance

2021-12-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/5/21 11:24 AM, Chris Katko wrote: All I want: ```d string ip_address = "192.168.1.1"; auto x = new InternetAddress( ip_string, "8008"); ``` ```d source/app.d(161,16): Error: none of the overloads of `this` are callable using argument types `(string, int)`

Re: d strings are the bane of my existance

2021-12-06 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 5 December 2021 at 16:37:21 UTC, Chris Katko wrote: Yes! Thank you! I just realized the latter part was broken when I switched to using a uint for the addr. But I didn't know string is an alias for immutable(char)[]! Thank you! Yeah, a `const(char)[]` argument is designed to accept

Re: d strings are the bane of my existance

2021-12-05 Thread Chris Katko via Digitalmars-d-learn
On Sunday, 5 December 2021 at 16:32:16 UTC, rikki cattermole wrote: The string is not the problem. ```d string ip_address = "192.168.1.1"; auto x = new InternetAddress(ip_address, 8008); ``` That works. A string in D is an alias for immutable(char)[]. This is defined in druntime (object.d).

Re: d strings are the bane of my existance

2021-12-05 Thread rikki cattermole via Digitalmars-d-learn
The string is not the problem. ```d string ip_address = "192.168.1.1"; auto x = new InternetAddress(ip_address, 8008); ``` That works. A string in D is an alias for immutable(char)[]. This is defined in druntime (object.d). Immutable does cast to const implicitly, so a string argument to

d strings are the bane of my existance

2021-12-05 Thread Chris Katko via Digitalmars-d-learn
All I want: ```d string ip_address = "192.168.1.1"; auto x = new InternetAddress( ip_string, "8008"); ``` ```d source/app.d(161,16): Error: none of the overloads of `this` are callable using argument types `(string, int)` /usr/include/dmd/phobos/std/socket.d(1472,5):Candidates are: