Re: general questions on reference types versus value types...

2014-12-01 Thread WhatMeWorry via Digitalmars-d-learn
Wow. This is great stuff! And diagrams are always appreciated. You should write a book. I'm off to play with emplace.

Re: curl: catching exception on connect.

2014-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 11/30/2014 10:38 PM, Suliman wrote: Am I right understand all exception are derived from assertThrown http://dlang.org/phobos/std_exception.html No, all exceptions are derived from Throwable. It has two descendants: - Error, representing conditions that are irrecoverable, and -

Re: general questions on reference types versus value types...

2014-12-01 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: you *can* allocate by-value types on the heap, e.g., `MyStruct* ptr = new MyStruct(...)`. But it's rare to want to do that; usually if you need to do that, you should just use a class instead. If I create data structures that contain many pointers, like some kinds of trees, I

Re: Problem interfacing with GSL

2014-12-01 Thread Arjan via Digitalmars-d-learn
On Sunday, 30 November 2014 at 16:26:53 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 30/11/14 13:21, Arjan via Digitalmars-d-learn wrote: Hi! D noob here. I'm trying to call this function from the GSL lib: Out of curiosity (since your question has already been answered),

Re: Problem interfacing with GSL

2014-12-01 Thread John Colvin via Digitalmars-d-learn
On Monday, 1 December 2014 at 12:17:46 UTC, Arjan wrote: On Sunday, 30 November 2014 at 16:26:53 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 30/11/14 13:21, Arjan via Digitalmars-d-learn wrote: Hi! D noob here. I'm trying to call this function from the GSL lib: Out of

Re: curl: catching exception on connect.

2014-12-01 Thread Suliman via Digitalmars-d-learn
Big thanks Ali! Only the small last question: why: string link = dlang.org; writeln(connect(link)); cause crash: std.net.curl.CurlException@C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl .d(779): HTTP request returned status code 400 0x00404263

Transform a sorted range to a range of ranges of equal elements

2014-12-01 Thread Tobias Pankrath via Digitalmars-d-learn
Basically I need std.algorithm.uniq or std.algorithm.group, but instead of a single element or an element and a number I want ranges that each contain consecutive elements considered equal. Example: [1,1, 2,2,2,3,4,4] - [1, 1], [2,2,2], [3], [4,4]. Let's call this uniqRange. This way

Re: Transform a sorted range to a range of ranges of equal elements

2014-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 01, 2014 at 06:37:13PM +, Tobias Pankrath via Digitalmars-d-learn wrote: Basically I need std.algorithm.uniq or std.algorithm.group, but instead of a single element or an element and a number I want ranges that each contain consecutive elements considered equal. Example:

Re: curl: catching exception on connect.

2014-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2014 10:25 AM, Suliman wrote: why: string link = dlang.org; writeln(connect(link)); cause crash: (To be pedantic: An unhandled exception is not a crash. ;) ) std.net.curl.CurlException@C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl .d(779): HTTP request

Re: curl: catching exception on connect.

2014-12-01 Thread Suliman via Digitalmars-d-learn
My guess is that you have to use HTTPS for CONNECT and that you have to have credentials for it. (?) Ali dlang.org should work on HTTP, but not HTTPS. Also I do not think that when I connect to HTTPS I should have any credentials. It's mostly like issue with curl...

Re: general questions on reference types versus value types...

2014-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2014 12:06 AM, WhatMeWorry wrote: Wow. This is great stuff! And diagrams are always appreciated. You should write a book. Agreed! H. S. Teoh, should I translate this post for the Turkish audience or should I wait for an article version of it first? ;) We can even reddit it

Re: general questions on reference types versus value types...

2014-12-01 Thread Suliman via Digitalmars-d-learn
Could anybody explain why there is opinion that stack is fast and the heap is slow. All of them are located in the same memory. So the access time should be equal.

Re: general questions on reference types versus value types...

2014-12-01 Thread ketmar via Digitalmars-d-learn
On Mon, 01 Dec 2014 20:22:59 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Could anybody explain why there is opinion that stack is fast and the heap is slow. All of them are located in the same memory. So the access time should be equal. could anybody

Re: general questions on reference types versus value types...

2014-12-01 Thread bearophile via Digitalmars-d-learn
Suliman: Could anybody explain why there is opinion that stack is fast and the heap is slow. All of them are located in the same memory. So the access time should be equal. Often the access speed is not exactly the same, because the stack memory is usually hotter, this means it's more often

Re: general questions on reference types versus value types...

2014-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/14 3:22 PM, Suliman wrote: Could anybody explain why there is opinion that stack is fast and the heap is slow. All of them are located in the same memory. So the access time should be equal. Measure it :) But short answer is twofold: 1. stack is usually hot in the local processor

Re: general questions on reference types versus value types...

2014-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 01, 2014 at 08:22:59PM +, Suliman via Digitalmars-d-learn wrote: Could anybody explain why there is opinion that stack is fast and the heap is slow. All of them are located in the same memory. So the access time should be equal. That may be true 15 years ago, it's not true

Re: general questions on reference types versus value types...

2014-12-01 Thread via Digitalmars-d-learn
On Monday, 1 December 2014 at 20:23:00 UTC, Suliman wrote: Could anybody explain why there is opinion that stack is fast and the heap is slow. All of them are located in the same memory. So the access time should be equal. Yes, the problem is that if you load from a memory area (of 64 bytes)

Re: Transform a sorted range to a range of ranges of equal elements

2014-12-01 Thread Tobias Pankrath via Digitalmars-d-learn
Phobos git HEAD has a new range adaptor called groupBy that does what you want: assert([1,1,2,2,2,3,4,4].groupBy!((a)=a).equal( [[1,1], [2,2,2], [3], [4,4]] )) T Thanks! I wonder if this works with all input ranges. As I see it, every implementation will

Re: Transform a sorted range to a range of ranges of equal elements

2014-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 02, 2014 at 01:03:12AM +, Tobias Pankrath via Digitalmars-d-learn wrote: Phobos git HEAD has a new range adaptor called groupBy that does what you want: assert([1,1,2,2,2,3,4,4].groupBy!((a)=a).equal( [[1,1], [2,2,2], [3], [4,4]] )) T