Re: std.net.curl : Performance

2020-11-09 Thread Vino via Digitalmars-d-learn
On Monday, 9 November 2020 at 20:57:33 UTC, Daniel Kozak wrote: On Mon, Nov 9, 2020 at 9:50 PM rinfz via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: On Monday, 9 November 2020 at 20:40:59 UTC, rinfz wrote: > On Monday, 9 November 2020 at 19:55:07 UTC, Vino wrote: >> ... >

Re: C++ or D?

2020-11-09 Thread realhet via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 01:00:50 UTC, Mark wrote: Hi all, my question would be about using D or not using D. Here are some things you will NOT get in D: youtube -> Dconf 2014 Day 2 Keynote: The Last Thing D Needs -- Scott Meyers For example, you will not get neurosis from it, or

Re: C++ or D?

2020-11-09 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 01:00:50 UTC, Mark wrote: Hi all, Anyone have any thoughts how C++ and D compare? C++ has a bit more mathematical feeling, everything has been sorted out in the spec, even if the rules are crazy difficult. D feels like it's up to _you_ to write the spec as

Re: C++ or D?

2020-11-09 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Nov 10, 2020 at 01:00:50AM +, Mark via Digitalmars-d-learn wrote: [...] > my question would be about using D or not using D. Is the newest C++ > iteration any good compared to D? [...] > I haven't looked into the newest C++. In theory, they might have added > something helpful in the

Re: C++ or D?

2020-11-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 01:00:50 UTC, Mark wrote: Anyone have any thoughts how C++ and D compare? Broadly speaking: D has a better core language, and C++ has a much better library and tooling ecosystem.

C++ or D?

2020-11-09 Thread Mark via Digitalmars-d-learn
Hi all, my question would be about using D or not using D. Is the newest C++ iteration any good compared to D? The reason I haven't used C++ anymore for years is that I was too naive sometimes. I tried to use new features in Visual C++, found myself being like a beta-tester for some things.

Re: Value based overload resolution?

2020-11-09 Thread Paul Backus via Digitalmars-d-learn
On Monday, 9 November 2020 at 22:04:55 UTC, kdevel wrote: It appears to me that the overload resolution may depend on the /value/ of the function argument. According to [1] the type of 1 is int and that of 1L is long. Thus I would have expected foo!int and foo!long being called in those cases.

Re: Value based overload resolution?

2020-11-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 November 2020 at 22:04:55 UTC, kdevel wrote: It appears to me that the overload resolution may depend on the /value/ of the function argument. According to [1] the type of 1 is int and that of 1L is long. That's not exactly true because of value range propagation. It is weird in

Value based overload resolution?

2020-11-09 Thread kdevel via Digitalmars-d-learn
Today I came across this: ~~~id.d import std.stdio : writeln; T foo (T) (T s) { __PRETTY_FUNCTION__.writeln; return s; } short foo (short s) { __PRETTY_FUNCTION__.writeln; return s; } T id (T) (T t) { return t; } int main () { foo (1); foo (1L); foo (id (1)); foo

Re: std.net.curl : Performance

2020-11-09 Thread Daniel Kozak via Digitalmars-d-learn
On Mon, Nov 9, 2020 at 9:50 PM rinfz via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Monday, 9 November 2020 at 20:40:59 UTC, rinfz wrote: > > On Monday, 9 November 2020 at 19:55:07 UTC, Vino wrote: > >> ... > > > > The only curl option you need to set within the loop is

Re: std.net.curl : Performance

2020-11-09 Thread rinfz via Digitalmars-d-learn
On Monday, 9 November 2020 at 20:40:59 UTC, rinfz wrote: On Monday, 9 November 2020 at 19:55:07 UTC, Vino wrote: ... The only curl option you need to set within the loop is the CurlOption.url. So your foreach block should look more like: foreach (...) { string url = chain(apihost,

Re: std.net.curl : Performance

2020-11-09 Thread rinfz via Digitalmars-d-learn
On Monday, 9 November 2020 at 19:55:07 UTC, Vino wrote: ... The only curl option you need to set within the loop is the CurlOption.url. So your foreach block should look more like: foreach (...) { string url = chain(apihost, only(':'), to!string(apiport), apiuri).to!string;

Re: std.net.curl : Performance

2020-11-09 Thread Daniel Kozak via Digitalmars-d-learn
Just delete it On Mon, Nov 9, 2020 at 9:00 PM Vino via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi All, > >Request your help to on how to improve the performance of the > below code. > > import std.conv: to; > import std.net.curl : get, HTTP, CurlOption; > import

std.net.curl : Performance

2020-11-09 Thread Vino via Digitalmars-d-learn
Hi All, Request your help to on how to improve the performance of the below code. import std.conv: to; import std.net.curl : get, HTTP, CurlOption; import std.parallelism: parallel; import std.range: chain, only; import std.typecons: Tuple, tuple; void main () { Array!(Tuple!(int,string))

Re: Extract sub string from a string

2020-11-09 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Monday, 9 November 2020 at 18:55:44 UTC, Ali Çehreli wrote: On 11/9/20 9:53 AM, k2aj wrote: > string text = "welcome2worldinfo"; > string hg = toUpper(text[0..7] ~ "-" ~ text[7..8] ~ "-" ~ text[8..13]); If those concatenations with the ~ operators prove to be costly at runtime, the

Re: Extract sub string from a string

2020-11-09 Thread Vino via Digitalmars-d-learn
On Monday, 9 November 2020 at 18:55:44 UTC, Ali Çehreli wrote: On 11/9/20 9:53 AM, k2aj wrote: > string text = "welcome2worldinfo"; > string hg = toUpper(text[0..7] ~ "-" ~ text[7..8] ~ "-" ~ text[8..13]); If those concatenations with the ~ operators prove to be costly at runtime, the

Re: Extract sub string from a string

2020-11-09 Thread Ali Çehreli via Digitalmars-d-learn
On 11/9/20 9:53 AM, k2aj wrote: > string text = "welcome2worldinfo"; > string hg = toUpper(text[0..7] ~ "-" ~ text[7..8] ~ "-" ~ text[8..13]); If those concatenations with the ~ operators prove to be costly at runtime, the following range expression may be faster because it does not allocate

Re: Extract sub string from a string

2020-11-09 Thread k2aj via Digitalmars-d-learn
On Monday, 9 November 2020 at 16:00:28 UTC, Vino wrote: Hi All, Request your help on how to extract sub string from a string, below is an example in PHP, need your help on how to do the same in D. $text = "welcome2worldinfo"; $hg = strtoupper(substr($text , 0, 7).'-'.substr($text, 7,

Re: Extract sub string from a string

2020-11-09 Thread Виталий Фадеев via Digitalmars-d-learn
On Monday, 9 November 2020 at 16:00:28 UTC, Vino wrote: Hi All, Request your help on how to extract sub string from a string, below is an example in PHP, need your help on how to do the same in D. $text = "welcome2worldinfo"; $hg = strtoupper(substr($text , 0, 7).'-'.substr($text, 7,

Re: Unicode Regular Expressions

2020-11-09 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 09, 2020 at 03:39:05PM +, Per Nordlöw via Digitalmars-d-learn wrote: > Is there any library that can deal with decoding and generating > character matchers for Unicode regular expression described at > > https://www.regular-expressions.info/unicode.html I'm pretty sure std.regex

Re: DMD: invalid UTF character `\U0000d800`

2020-11-09 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:47:34 UTC, Per Nordlöw wrote: Can I just do, for instance, cast(dchar)0xd8000 for `\Ud800` to accomplish this? There's also: dchar(0xd8000)

Extract sub string from a string

2020-11-09 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to extract sub string from a string, below is an example in PHP, need your help on how to do the same in D. $text = "welcome2worldinfo"; $hg = strtoupper(substr($text , 0, 7).'-'.substr($text, 7, 1).'-'.substr($text, 8, 5)); print_r($hg) \\ Output :

Re: asdf get first value from a json string.

2020-11-09 Thread Vino via Digitalmars-d-learn
On Sunday, 8 November 2020 at 19:31:50 UTC, frame wrote: On Sunday, 8 November 2020 at 19:29:39 UTC, frame wrote: On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below,

Unicode Regular Expressions

2020-11-09 Thread Per Nordlöw via Digitalmars-d-learn
Is there any library that can deal with decoding and generating character matchers for Unicode regular expression described at https://www.regular-expressions.info/unicode.html

Re: New vs length on dymamic array

2020-11-09 Thread Виталий Фадеев via Digitalmars-d-learn
On Monday, 9 November 2020 at 09:05:58 UTC, Imperatorn wrote: On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; You can check

Re: New vs length on dymamic array

2020-11-09 Thread user1234 via Digitalmars-d-learn
On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; It's the same. If the two are valid then you are in a function. So it's an

Re: New vs length on dymamic array

2020-11-09 Thread Daniel Kozák via Digitalmars-d-learn
On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; In theory auto array = new wchar[111]; // or new wchar[](111); should do less

Re: New vs length on dymamic array

2020-11-09 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Monday, 9 November 2020 at 09:05:58 UTC, Imperatorn wrote: On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; You can check

Re: New vs length on dymamic array

2020-11-09 Thread Imperatorn via Digitalmars-d-learn
On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; You can check using compiler explorer: https://godbolt.org/

New vs length on dymamic array

2020-11-09 Thread Andrey via Digitalmars-d-learn
Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111;