Re: Convering strings containing number

2022-06-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 04:26:44 UTC, Salih Dincer wrote: Hi, I've been interested in conversion possibilities for a while. I tried to convert a string containing numbers but with no success in single digits. The only solution I found is to subtract 48 from the result: ```d import

Convering strings containing number

2022-06-14 Thread Salih Dincer via Digitalmars-d-learn
Hi, I've been interested in conversion possibilities for a while. I tried to convert a string containing numbers but with no success in single digits. The only solution I found is to subtract 48 from the result: ```d import std; void main() {    string str = "abc123";    

Re: Comparing Exceptions and Errors

2022-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
I don't see what you see wrong with the code I wrote. It's straightforward, obvious, and does the job I need it to do, in a way that's not prone to future mistakes. I explained why, but you don't agree with the explanation. That's OK, we don't all have to write the same exact systems. D is a

Re: Bug in dmd?

2022-06-14 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 21:44:48 UTC, Dukc wrote: No idea. The functions seems indeed to be exactly the same, so I assume this is a DMD bug. It cannot be a bug in `std.sumtype`, since that would trigger in both of the templates. This definitely triggers some bug in DMD because this

Re: Comparing Exceptions and Errors

2022-06-14 Thread kdevel via Digitalmars-d-learn
On Monday, 13 June 2022 at 13:15:42 UTC, Steven Schveighoffer wrote: Possibly, but I don't close the handle. It goes back to a pool to get reused. Um. I need a (fresh) connection per CGI process. I wonder if nowadays the TLS startup between the browser and the webserver isn't at least one

Re: Bug in dmd?

2022-06-14 Thread Dukc via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote: I have [pretty simple code in my library](https://github.com/andrey-zherikov/argparse/blob/bug/source/argparse/help.d#L27-L47): ```d alias CC = SumType!(AA,BB); struct AA {} struct BB { CC[] c; } private void ppp(T,

Re: Bug?

2022-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/22 3:35 PM, JG wrote: Hi, Is this a bug? ```d import std; template test(alias f) {     auto test(I)(I i) { return f(i); } } void main() {     alias t = test!(x=>x+1);     1.t.writeln; //<--Doesn't compile     1.test!(x=>x+1).writeln;     t(1).writeln; } ``` Not a bug. Local

Bug?

2022-06-14 Thread JG via Digitalmars-d-learn
Hi, Is this a bug? ```d import std; template test(alias f) { auto test(I)(I i) { return f(i); } } void main() { alias t = test!(x=>x+1); 1.t.writeln; //<--Doesn't compile 1.test!(x=>x+1).writeln; t(1).writeln; } ```

Re: Closures over temporary variables

2022-06-14 Thread Ali Çehreli via Digitalmars-d-learn
On 6/14/22 02:04, bauss wrote: > You have to do it like this: > > ``` > dgs ~= ( (n) => () { writeln(n); })(i); > ``` The same thing with a named function as well as with iota(): import std.range; import std.algorithm; import std.stdio; void main() { void delegate()[] dgs; auto

Re: ImportC: unresolved external symbol

2022-06-14 Thread ryuukk_ via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 14:38:17 UTC, Mike Parker wrote: On Tuesday, 14 June 2022 at 14:32:50 UTC, ryuukk_ wrote: ``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub

Re: ImportC: unresolved external symbol

2022-06-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 14:32:50 UTC, ryuukk_ wrote: ``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub init) DMD: v2.100.0-dirty This works from the command line:

ImportC: unresolved external symbol

2022-06-14 Thread ryuukk_ via Digitalmars-d-learn
Hello Tried to give ImportC a try to finally get rid of gluecode in one of my project, but this simple test gives me a compile error: nk.c ``` int test(void) { return 1; } ``` app.d ``` import std.stdio; import nk = nk; void main() { if (nk.test() != 0) {

Bug in dmd?

2022-06-14 Thread Andrey Zherikov via Digitalmars-d-learn
I have [pretty simple code in my library](https://github.com/andrey-zherikov/argparse/blob/bug/source/argparse/help.d#L27-L47): ```d alias CC = SumType!(AA,BB); struct AA {} struct BB { CC[] c; } private void ppp(T, Output)(auto ref Output output, in CommandArguments!T cmd, in Config

Re: Closures over temporary variables

2022-06-14 Thread bauss via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 08:26:53 UTC, Anonymouse wrote: What is the correct way of making this output `0 1 2`? ```d void delegate()[] dgs; foreach (immutable i; 0..3) { dgs ~= () => writeln(i); } foreach (dg; dgs) { dg(); // outputs: `2 2 2` } ``` You have to do it like this:

how to set REST path for gcloud api in vibe.d?

2022-06-14 Thread MichaelBi via Digitalmars-d-learn
I need to use gcloud NLP api which has the url and endpoint like this "https://language.googleapis.com/v1beta2/documents:analyzeSentiment;. The ":" between documents and analyzeSentiment make a lot trouble for me. Just don't know how to setup the @path in RestInterface for such endpoint. I tried

Closures over temporary variables

2022-06-14 Thread Anonymouse via Digitalmars-d-learn
What is the correct way of making this output `0 1 2`? ```d void delegate()[] dgs; foreach (immutable i; 0..3) { dgs ~= () => writeln(i); } foreach (dg; dgs) { dg(); // outputs: `2 2 2` } ```