Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 23 March 2022 at 00:51:42 UTC, Era Scarecrow wrote: On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote: We already have this: import std.conv : to; int x; long y; y = x.to!long; // equivalent to straight assignment / cast x =

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote: On Tue, Mar 22, 2022 at 09:11 PM, Era Scarecrow wrote: [...] I'd almost wish D had a more lenient mode and would do automatic down-casting, then complain if it *would* have failed to downcast data at runtime. [...] We already

Re: Basic question about size_t and ulong

2022-03-22 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 22, 2022 at 09:11:00PM +, Era Scarecrow via Digitalmars-d-learn wrote: [...] > I'd almost wish D had a more lenient mode and would do automatic > down-casting, then complain if it *would* have failed to downcast data > at runtime. [...] We already have this: import

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 18:47:19 UTC, Ali Çehreli wrote: On 3/22/22 11:28, Era Scarecrow wrote: > So when should you use size_t? I use size_t for anything that is related to count, index, etc. However, this is a contested topic because size_t is unsigned. I don't see a problem with

Re: I like dlang but i don't like dub

2022-03-22 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 22, 2022 at 05:36:13PM +, IGotD- via Digitalmars-d-learn wrote: > On Friday, 18 March 2022 at 18:16:51 UTC, Ali Çehreli wrote: > > > > The first time I learned about pulling in dependencies terrified me. [...] > >

Re: Basic question about size_t and ulong

2022-03-22 Thread Ali Çehreli via Digitalmars-d-learn
On 3/22/22 11:28, Era Scarecrow wrote: > So when should you use size_t? I use size_t for anything that is related to count, index, etc. However, this is a contested topic because size_t is unsigned. As soon as you use it in an expression, the whole expression becomes unsigned as well.

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 18 March 2022 at 23:01:05 UTC, Ali Çehreli wrote: P.S. On a related note, I used to make the mistake of using size_t for file offsets as well. That is a mistake because even on a 32-bit system (or build), file sizes can be larger than uint.max. So, the correct type is long for

Re: I like dlang but i don't like dub

2022-03-22 Thread IGotD- via Digitalmars-d-learn
On Friday, 18 March 2022 at 18:16:51 UTC, Ali Çehreli wrote: The first time I learned about pulling in dependencies terrified me. (This is the part I realize I am very different from most other programmers.) I am still terrified that my dependency system will pull in a tree of code that I

Re: I like dlang but i don't like dub

2022-03-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 14:44:59 UTC, Marcone wrote: Why is dmd unable to import modules installed by dub using the import command like it does with the Phobos library? He can't send these modules to Linker? Needing to be passed to dmd via command line. I think it could be all automatic.

Re: Determining function template from runtime type: better ideas?

2022-03-22 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 22, 2022 at 07:09:07AM +, cc via Digitalmars-d-learn wrote: > Sorry for the fairly lengthy post. I'm wondering if there are any > suggested good practices in place for calling templated functions > using the runtime type of an object, e.g. what `typeid(object)` > returns. [[...]

Re: I like dlang but i don't like dub

2022-03-22 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 14:44:59 UTC, Marcone wrote: Why is dmd unable to import modules installed by dub using the import command like it does with the Phobos library? He can't send these modules to Linker? Needing to be passed to dmd via command line. I think it could be all automatic.

How can I implement SSL protocol in my program?

2022-03-22 Thread Marcone via Digitalmars-d-learn
/* Direct DropBear Dlang Injector. Created by Marcone (thegrapev...@email.com) in 2019. */ import std; import core.thread; import core.stdc.stdlib; // Configuracoes. string LISTEN_PORT = "127.0.0.1:8088"; string PAYLOAD = "GET / HTTP/1.1\r\nhost: www.bing.com\r\n\r\n";

Re: I like dlang but i don't like dub

2022-03-22 Thread Marcone via Digitalmars-d-learn
Why is dmd unable to import modules installed by dub using the import command like it does with the Phobos library? He can't send these modules to Linker? Needing to be passed to dmd via command line. I think it could be all automatic.

Re: Printing a quoted string

2022-03-22 Thread cc via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 07:18:00 UTC, cc wrote: On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote: Hi, I also need a function to "unquote" string, like this: ```d assert(unquote(`\n`)=="\n"); ``` Is there a way to do that? I rolled my own for that recently: ```d string dequote(string

Re: Printing a quoted string

2022-03-22 Thread cc via Digitalmars-d-learn
On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote: Hi, I also need a function to "unquote" string, like this: ```d assert(unquote(`\n`)=="\n"); ``` Is there a way to do that? I rolled my own for that recently: ```d string dequote(string str) @safe pure { if (str.length < 2)

Determining function template from runtime type: better ideas?

2022-03-22 Thread cc via Digitalmars-d-learn
Sorry for the fairly lengthy post. I'm wondering if there are any suggested good practices in place for calling templated functions using the runtime type of an object, e.g. what `typeid(object)` returns. Consider the following situation: ```d class Person { string name; int