Re: User defined type and foreach

2017-11-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 17 November 2017 at 03:15:12 UTC, Tony wrote: Thanks T! Good information, especially "iterating over a range is supposed to consume it". I have been reading dlang.org->Documentation->Language Reference, but should have also read dlang.org->Dlang-Tour->Ranges. Although that page

Re: writeln, alias this and dynamic arrays.

2017-11-16 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: [...] as is it produces: [1, 2, 3, 4, 5, 6, 7, 8] [] I expected it to produce: [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8] And with the toString override included it does. Why does the version without the toString override ou

Re: writeln, alias this and dynamic arrays.

2017-11-16 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 17 November 2017 at 02:16:35 UTC, Michael V. Franklin wrote: On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: And with the toString override included it does. Why does the version without the toString override output an empty array? I think that is due to this bug: h

Re: ESR on post-C landscape

2017-11-16 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Friday, 17 November 2017 at 00:36:21 UTC, codephantom wrote: On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: Uhm, no? What do you mean by 'primary focus of program design' and in which context? I the context that, this is specifically what Stroustrup says in h

Re: How to define variadic delegate with a ref/out argument?

2017-11-16 Thread Jerry A. via Digitalmars-d-learn
On Friday, 17 November 2017 at 05:08:23 UTC, pham wrote: struct DelegateList(Args...) { public: alias DelegateHandler = void delegate(Args args) nothrow; DelegateHandler[] items; void opCall(Args args) nothrow { foreach (i; items) i(args); } } DelegateLi

How to define variadic delegate with a ref/out argument?

2017-11-16 Thread pham via Digitalmars-d-learn
struct DelegateList(Args...) { public: alias DelegateHandler = void delegate(Args args) nothrow; DelegateHandler[] items; void opCall(Args args) nothrow { foreach (i; items) i(args); } } DelegateList!(string, int) list; // Compile OK so far DelegateList!(

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Friday, 17 November 2017 at 01:16:38 UTC, H. S. Teoh wrote: It should be .empty, .popFront, and .front, not .pop. Also, these methods are *range* primitives, and over time, we have come to a consensus that generally speaking, it's a bad idea to conflate containers with ranges over contain

Re: writeln, alias this and dynamic arrays.

2017-11-16 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: And with the toString override included it does. Why does the version without the toString override output an empty array? I think that is due to this bug: https://issues.dlang.org/show_bug.cgi?id=13189 It's actually on my todo

writeln, alias this and dynamic arrays.

2017-11-16 Thread matthewh via Digitalmars-d-learn
I am new to D and have been fiddling with bits and pieces. I have this code: import std.stdio : writeln; import std.format : format; class Base { override { //string toString() //{ // return format("%s", store); //} } ubyte[] store; alias st

Re: User defined type and foreach

2017-11-16 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 17, 2017 at 01:06:31AM +, Tony via Digitalmars-d-learn wrote: [...] > But I do have a complaint about the methods empty(), popFront() and > pop(). I think they should have a special syntax or name to reflect > that they are not general purpose methods. __empty() or preferably > __fo

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:34:54 UTC, Steven Schveighoffer wrote: On 11/16/17 8:10 AM, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() rout

Re: ESR on post-C landscape

2017-11-16 Thread codephantom via Digitalmars-d-learn
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: Uhm, no? What do you mean by 'primary focus of program design' and in which context? I the context that, this is specifically what Stroustrup says in his book (The Design and Evolution of C++ 1994) "Simula's class

Re: ESR on post-C landscape

2017-11-16 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 16 November 2017 at 22:27:58 UTC, sarn wrote: In the 90s (and a bit into the 00s) there was a pretty extreme "everything must be an object; OO is the solution to everything" movement in the industry. Yes, around 1991, the computer mags were all over C++ and the bookshelves in the

Re: ESR on post-C landscape

2017-11-16 Thread sarn via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 09:43:07 UTC, Ola Fosheim Grøstad wrote: ESR got famous for his cathedral vs bazaar piece, which IMO was basically just a not very insightful allegory over waterfall vs evolutionary development models, but since many software developers don't know the basics of s

Re: ESR on post-C landscape

2017-11-16 Thread sarn via Digitalmars-d-learn
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: On Thursday, 16 November 2017 at 11:24:09 UTC, codephantom I would never say OO itself is a failure. But the idea that is should be the 'primary focus of program design' .. I think that is a failure...and I think that pri

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
can you post both code, java and d, for sure we are all testing the sames On Thu, Nov 16, 2017 at 8:37 PM, ade90036 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > So, what is next? > > Can we enable some sort of profiling to see what is going on? >

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
So, what is next? Can we enable some sort of profiling to see what is going on?

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
Mediocre result... let me create a java equivalent program so we have a direct comparison.. These are the tests for a similar program in java. bombardier -c 200 -n 1 http://localhost:8081 Bombarding http://localhost:8081/ with 1 requests using 200 connections 1 / 1 [==

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
Result: bombardier -c 200 -n 1 http://localhost: Bombarding http://localhost: with 1 requests using 200 connections 1 / 1 [===] 100.00% 1m24s Done!

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:44:11 UTC, Daniel Kozak wrote: It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior Ok, let me force the: "defaultPoolThreads(8)" and let me re-test

Re: ESR on post-C landscape

2017-11-16 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:02:10 UTC, Patrick Schluter wrote: The shear amount of inscrutable cruft and rules, plus the moving target of continuously changing semantics an order or two of magnitude bigger than C added to the fact that you still need to know C's gotchas, makes it one or

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior On Thu, Nov 16, 2017 at 7:20 PM, Daniel Kozak wrote: > Hmm works ok for me. What OS? > > Dne 16. 11. 2017 12:05 dop. napsal uživatel "kd

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:20:36 UTC, Daniel Kozak wrote: Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn" : [...] I'm running MacOS..

Re: User defined type and foreach

2017-11-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/16/17 8:10 AM, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic

Re: ESR on post-C landscape

2017-11-16 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:06:22 UTC, Patrick Schluter wrote: On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad wrote: changing. C no longer models the hardware in a reasonable manner. Because of the flawed interpretation of UB by the compiler writers, not because of

Re: Inference of GC allocation scope

2017-11-16 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 16 November 2017 at 17:39:02 UTC, Petar Kirov [ZombineDev] wrote: https://github.com/ldc-developers/ldc/blob/master/gen/passes/GarbageCollect2Stack.cpp Does this include GC allocations that don't fit on stack?

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn" : > On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: > >> This one works ok for me, but I am on linux: >> https://dpaste.dzfl.pl/f54decee45bc >> > > It works, but it does

Re: ESR on post-C landscape

2017-11-16 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad wrote: On Tuesday, 14 November 2017 at 11:55:17 UTC, codephantom wrote: [...] Well, in another thread he talked about the Tango split, so not sure where he is coming from. [...] No, the starting point for C++ was that Simu

Re: ESR on post-C landscape

2017-11-16 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 09:43:07 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 14 November 2017 at 06:32:55 UTC, lobo wrote: "[snip]...Then came the day we discovered that a person we incautiously gave commit privileges to had fucked up the games’s AI core. It became apparent that I was t

Re: Inference of GC allocation scope

2017-11-16 Thread Petar via Digitalmars-d-learn
On Thursday, 16 November 2017 at 17:29:56 UTC, Nordlöw wrote: Are there any plans on a compiler pass that finds scoped GC-allocations and makes their destructors deterministic similar to D's struct scope behaviour? https://github.com/ldc-developers/ldc/blob/master/gen/passes/GarbageCollect2Sta

Inference of GC allocation scope

2017-11-16 Thread Nordlöw via Digitalmars-d-learn
Are there any plans on a compiler pass that finds scoped GC-allocations and makes their destructors deterministic similar to D's struct scope behaviour?

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
On Wednesday, 15 November 2017 at 23:04:46 UTC, kdevel wrote: On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: This one works ok for me, but I am on linux: https://dpaste.dzfl.pl/f54decee45bc It works, but it does not handle two connects in parallel. STR: 1. start the binar

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 13:35:13 UTC, Tony wrote: On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFr

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, ra

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 12:56:18 UTC, Steven Schveighoffer wrote: On 11/16/17 3:03 AM, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow i

Re: User defined type and foreach

2017-11-16 Thread ag0aep6g via Digitalmars-d-learn
On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. https://issues.dlang.org/sho

Re: User defined type and foreach

2017-11-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/16/17 3:03 AM, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the

Re: ESR on post-C landscape

2017-11-16 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Thursday, 16 November 2017 at 11:24:09 UTC, codephantom wrote: On Thursday, 16 November 2017 at 06:35:30 UTC, Ola Fosheim Grostad wrote: Yes, I agree that classes are a powerful modelling primitive, but my point was that Stroustrup made classes the 'primary focus of program design'. Yes, tha

Re: ESR on post-C landscape

2017-11-16 Thread codephantom via Digitalmars-d-learn
On Thursday, 16 November 2017 at 06:35:30 UTC, Ola Fosheim Grostad wrote: No, classes is a powerful modelling primitive. C++ got that right. C++ is also fairly uniform because of it. Yes, I agree that classes are a powerful modelling primitive, but my point was that Stroustrup made classes the

Re: User defined type and foreach

2017-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 16, 2017 08:43:17 Tony via Digitalmars-d-learn wrote: > On Thursday, 16 November 2017 at 08:26:25 UTC, Andrea Fontana > > wrote: > > On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: > >> I made a stack data type and created an opIndex() so it could > >> be turned int

Re: Treating a slice as an InputRange

2017-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 15, 2017 22:48:12 unleashy via Digitalmars-d-learn wrote: > On Wednesday, 15 November 2017 at 21:02:35 UTC, Jonathan M Davis > wrote: > > If you specifically want a function to accept a range and > > mutate it without returning it, then it should take its > > argument by ref

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 08:26:25 UTC, Andrea Fontana wrote: On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, w

Re: User defined type and foreach

2017-11-16 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use t

User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a