Re: Using std.net.curl

2020-02-28 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 29 February 2020 at 03:53:37 UTC, David Anderson wrote: I want to capture that text in a variable, but the upload function returns void. How can I get the text returned by the web server to be stored in a variable? import std; auto updata = read("inputfile"); auto dldata =

Using std.net.curl

2020-02-28 Thread David Anderson via Digitalmars-d-learn
I'm working with std.net.curl. Using curl on the command line I can do this: curl -T file.txt http://localhost:9998/tika and it returns text as a result. When I attempt to do the same thing in D code as follows: import std.net.curl; upload("file.txt",

Re: Should getSymbolsByUDA work with member variables?

2020-02-28 Thread Basile B. via Digitalmars-d-learn
On Friday, 28 February 2020 at 18:34:08 UTC, cc wrote: This compiles: class Foo { int x; @(1) void y() {} this() { static foreach (idx, field; getSymbolsByUDA!(Foo, 1)) { } } } This does not: class Foo { @(1) int x;

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-28 Thread Basile B. via Digitalmars-d-learn
On Thursday, 27 February 2020 at 21:46:08 UTC, Bruce Carneal wrote: On Thursday, 27 February 2020 at 19:46:23 UTC, Basile B. wrote: [...] The code below is the test jig that I'm using currently. It is adopted from yours but has added the -d=distribution command line option. [...] Yes I

Should getSymbolsByUDA work with member variables?

2020-02-28 Thread cc via Digitalmars-d-learn
This compiles: class Foo { int x; @(1) void y() {} this() { static foreach (idx, field; getSymbolsByUDA!(Foo, 1)) { } } } This does not: class Foo { @(1) int x; void y() {} this() { static

Re: How to sum multidimensional arrays?

2020-02-28 Thread bachmeier via Digitalmars-d-learn
On Friday, 28 February 2020 at 16:51:10 UTC, AB wrote: See https://dlang.org/spec/operatoroverloading.html#array-ops for a better overview of the required operators or mir.ndslice for an nD implementation. Here's an old version of some of the things I've been using:

Re: How to sum multidimensional arrays?

2020-02-28 Thread AB via Digitalmars-d-learn
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote: I'd like to sum 2D arrays. Let's create 2 random 2D arrays and sum them. ``` import std.random : Xorshift, unpredictableSeed, uniform; import std.range : generate, take, chunks; import std.array : array; static T[][]

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-28 Thread 9il via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:11:23 UTC, Bruce Carneal wrote: On Friday, 28 February 2020 at 06:50:55 UTC, 9il wrote: On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: So after reading the translation of RYU I was interested too see if the decimalLength() function can be

Re: preset counter variable in a for loop

2020-02-28 Thread Namal via Digitalmars-d-learn
On Friday, 28 February 2020 at 12:48:17 UTC, mipri wrote: On Friday, 28 February 2020 at 12:44:52 UTC, Namal wrote: Hello, I don't understand why this simple code causes a compiler error.. import std.stdio; void main(){ int b = 0; for (b; b<3; b++){ writeln(b); } }

Re: preset counter variable in a for loop

2020-02-28 Thread mipri via Digitalmars-d-learn
On Friday, 28 February 2020 at 12:44:52 UTC, Namal wrote: Hello, I don't understand why this simple code causes a compiler error.. import std.stdio; void main(){ int b = 0; for (b; b<3; b++){ writeln(b); } } $Error: b has no effect Well, that's the error. b has no

preset counter variable in a for loop

2020-02-28 Thread Namal via Digitalmars-d-learn
Hello, I don't understand why this simple code causes a compiler error.. import std.stdio; void main(){ int b = 0; for (b; b<3; b++){ writeln(b); } } $Error: b has no effect Same works perfectly fine in C++ #include int main(){ int i = 0; for(i; i<3; i++)

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-28 Thread kinke via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:11:23 UTC, Bruce Carneal wrote: On Friday, 28 February 2020 at 06:50:55 UTC, 9il wrote: bsr can be done in one/two CPU operation, quite quick. But core.bitop.bsr wouldn't be inlined. Instead, mir-core (mir.bitop: ctlz) or LDC intrinsics llvm_ctlz can be used

Re: Call method if declared only

2020-02-28 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:33:11 UTC, Виталий Фадеев wrote: Thanks all ! I happy ! Check this one: void On( T, M )( T o, M message ) { [snip] void main() { auto a = new A(); a.Send( a, WM_KEYUP ); a.Send( a, WM_KEYDOWN ); } That does mostly

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-28 Thread Bruce Carneal via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:11:23 UTC, Bruce Carneal wrote: On Friday, 28 February 2020 at 06:50:55 UTC, 9il wrote: On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: So after reading the translation of RYU I was interested too see if the decimalLength() function can be

Re: Call method if declared only

2020-02-28 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:20:03 UTC, Виталий Фадеев wrote: On Friday, 28 February 2020 at 10:14:41 UTC, Виталий Фадеев wrote: On Friday, 28 February 2020 at 09:49:53 UTC, Simen Kjærås wrote: On Friday, 28 February 2020 at 09:25:58 UTC, Виталий Фадеев wrote: [...] So let's create a

Re: Call method if declared only

2020-02-28 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:14:41 UTC, Виталий Фадеев wrote: On Friday, 28 February 2020 at 09:49:53 UTC, Simen Kjærås wrote: On Friday, 28 February 2020 at 09:25:58 UTC, Виталий Фадеев wrote: [...] So let's create a template for that: [...] Cool! Think! I writing code generation.

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-28 Thread Bruce Carneal via Digitalmars-d-learn
On Friday, 28 February 2020 at 06:50:55 UTC, 9il wrote: On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: So after reading the translation of RYU I was interested too see if the decimalLength() function can be written to be faster, as it cascades up to 8 CMP. [...] bsr can

Re: Call method if declared only

2020-02-28 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 09:49:53 UTC, Simen Kjærås wrote: On Friday, 28 February 2020 at 09:25:58 UTC, Виталий Фадеев wrote: [...] So let's create a template for that: [...] Cool!

Re: Call method if declared only

2020-02-28 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 28 February 2020 at 09:25:58 UTC, Виталий Фадеев wrote: Yes. Thank ! I read it. Problem is - OS has many messages + user messages... It mean what interfaces like IKeyDown must me declared. All. Dream on write less code... So let's create a template for that: interface

Re: Call method if declared only

2020-02-28 Thread drug via Digitalmars-d-learn
On 2/28/20 12:25 PM, Виталий Фадеев wrote: Now I reading Template doc for up skill... I recommend this nice tutorial https://github.com/PhilippeSigaud/D-templates-tutorial

Re: Call method if declared only

2020-02-28 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 09:12:38 UTC, Simen Kjærås wrote: On Friday, 28 February 2020 at 06:12:37 UTC, Виталий Фадеев wrote: Searching solution for idea ! For whatever reason, it seems my attempts at answering this earlier has disappeared into the void. Here: import

Re: preset counter variable in a for loop --> 'has no effect' Error

2020-02-28 Thread drug via Digitalmars-d-learn
On 2/28/20 11:48 AM, Namal wrote: Hello, I don't understand why this simple code causes a compiler error.. import std.stdio; void main(){  int b = 0;  for (b; b<3; b++){    writeln(b);  } } $Error: b has no effect Same works perfectly fine in C++ #include int main(){  int i = 0;

Re: Call method if declared only

2020-02-28 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 28 February 2020 at 06:12:37 UTC, Виталий Фадеев wrote: Searching solution for idea ! For whatever reason, it seems my attempts at answering this earlier has disappeared into the void. Here: import core.sys.windows.windows; import std.stdio; class Base { LRESULT On(UINT

preset counter variable in a for loop --> 'has no effect' Error

2020-02-28 Thread Namal via Digitalmars-d-learn
Hello, I don't understand why this simple code causes a compiler error.. import std.stdio; void main(){ int b = 0; for (b; b<3; b++){ writeln(b); } } $Error: b has no effect Same works perfectly fine in C++ #include int main(){ int i = 0; for(i; i<3; i++)

Re: Call method if declared only

2020-02-28 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 08:36:53 UTC, mipri wrote: On Friday, 28 February 2020 at 08:08:59 UTC, Виталий Фадеев wrote: [...] The pattern throughout Phobos is static tests, like isInputRange!R [...] It cool ! I will try ! Thank you !

Re: Call method if declared only

2020-02-28 Thread mipri via Digitalmars-d-learn
On Friday, 28 February 2020 at 08:08:59 UTC, Виталий Фадеев wrote: Searching for beauty readable code... The pattern throughout Phobos is static tests, like isInputRange!R So something like this: import std.stdio; import std.traits; template canOnKey(T) { static if

Re: Call method if declared only

2020-02-28 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 28 February 2020 at 08:08:59 UTC, Виталий Фадеев wrote: On Friday, 28 February 2020 at 06:12:37 UTC, Виталий Фадеев wrote: Searching solution for idea ! Goal is to get System message, dispatch/route to method ! If method implemented only ! I dream on in future write clean code of a

Re: Call method if declared only

2020-02-28 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 06:12:37 UTC, Виталий Фадеев wrote: Searching solution for idea ! Goal is to get System message, dispatch/route to method ! If method implemented only ! I dream on in future write clean code of a derived widgets like this : class Base { //