Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. ```D void main() { import std.stdio : writeln; auto r = [0,1,2,3]; auto f = delegate() const // Compiles even though we are chang

Re: Decompressing bzip2

2016-04-04 Thread Thomas Brix Larsen via Digitalmars-d-learn
On Sunday, 3 April 2016 at 02:03:29 UTC, stunaep wrote: I am trying to use the bzip2 bindings that are available on code.dlang.org/packages, but I am having a really hard time using it due to the pointers. It needs to be an array once it's decompressed. Here is what I have: import std.stdio;

Re: No aa.byKey.length?

2016-04-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 04, 2016 02:32:56 Yuxuan Shui via Digitalmars-d-learn wrote: > On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote: > > On Sunday, April 03, 2016 23:46:10 John Colvin via > > > > Digitalmars-d-learn wrote: > >> On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis

Re: Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 April 2016 at 08:10:10 UTC, Edwin van Leeuwen wrote: Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. Note that annotating with pure also doesn't help. As a result we can have

Re: Read only delegate

2016-04-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 4 April 2016 at 08:10:10 UTC, Edwin van Leeuwen wrote: Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. ``` Yeah this is a nasty old issue. The underlying problem is that a deleg

Re: Read only delegate

2016-04-04 Thread Kagamin via Digitalmars-d-learn
On Monday, 4 April 2016 at 11:32:23 UTC, Rene Zwanenburg wrote: https://issues.dlang.org/show_bug.cgi?id=1983 Bug 1983 is about usage of delegates after creation, restrictions during creation are enforced. AIU, OP wants to have const check during creation.

Re: Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 April 2016 at 11:32:23 UTC, Rene Zwanenburg wrote: On Monday, 4 April 2016 at 08:10:10 UTC, Edwin van Leeuwen wrote: Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. ``` Yeah t

Re: No aa.byKey.length?

2016-04-04 Thread John Colvin via Digitalmars-d-learn
On Monday, 4 April 2016 at 02:32:56 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote: On Sunday, April 03, 2016 23:46:10 John Colvin via Digitalmars-d-learn wrote: On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote: > [...] Maybe aa.byKey

Re: Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 April 2016 at 11:39:55 UTC, Kagamin wrote: On Monday, 4 April 2016 at 11:32:23 UTC, Rene Zwanenburg wrote: https://issues.dlang.org/show_bug.cgi?id=1983 Bug 1983 is about usage of delegates after creation, restrictions during creation are enforced. AIU, OP wants to have const ch

Re: Possible bug in RVO?

2016-04-04 Thread Anonymouse via Digitalmars-d-learn
On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: auto clobber(ref Set x, ref Set o) { Set ret; ret.aa = x.aa; assert(x.aa.length > 0); // <-- boom return ret; } No idea myself but that's

Re: Where do I learn to use GtkD

2016-04-04 Thread Karabuta via Digitalmars-d-learn
On Monday, 14 March 2016 at 03:46:02 UTC, Gerald wrote: On Sunday, 13 March 2016 at 19:53:35 UTC, karabuta wrote: On Sunday, 13 March 2016 at 19:34:36 UTC, WebFreak001 wrote: and in the (not quite complete) documentation you can find widgets you might want to use. Its a great place for getting

Catching thread creation error

2016-04-04 Thread tcak via Digitalmars-d-learn
In my server program, when a request comes, I create a new thread for that. I put memory limit to program with setrlimit. So, when the limit is reached, new thread cannot be created. I want to tell client back that there is system problem. But catching "Throwable" does not suffice for this i

Re: Catching thread creation error

2016-04-04 Thread tcak via Digitalmars-d-learn
On Monday, 4 April 2016 at 20:28:13 UTC, tcak wrote: In my server program, when a request comes, I create a new thread for that. I put memory limit to program with setrlimit. So, when the limit is reached, new thread cannot be created. I want to tell client back that there is system problem.

Re: Possible bug in RVO?

2016-04-04 Thread Ali Çehreli via Digitalmars-d-learn
On 04/04/2016 09:36 AM, Anonymouse wrote: On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: auto clobber(ref Set x, ref Set o) { Set ret; ret.aa = x.aa; assert(x.aa.length > 0); // <-- boom return ret; }

Re: Decompressing bzip2

2016-04-04 Thread stunaep via Digitalmars-d-learn
On Monday, 4 April 2016 at 08:26:07 UTC, Thomas Brix Larsen wrote: On Sunday, 3 April 2016 at 02:03:29 UTC, stunaep wrote: I am trying to use the bzip2 bindings that are available on code.dlang.org/packages, but I am having a really hard time using it due to the pointers. It needs to be an arra

Re: Where do I learn to use GtkD

2016-04-04 Thread Mike Wey via Digitalmars-d-learn
On 04/04/2016 09:33 PM, Karabuta wrote: On Monday, 14 March 2016 at 03:46:02 UTC, Gerald wrote: On Sunday, 13 March 2016 at 19:53:35 UTC, karabuta wrote: On Sunday, 13 March 2016 at 19:34:36 UTC, WebFreak001 wrote: and in the (not quite complete) documentation you can find widgets you might wa

unicode confusion

2016-04-04 Thread Charles Hixson via Digitalmars-d-learn
Well, at least I think that it's unicode confusion. When a store values into a string (in an array of structs) and then compare it against itself, it compares fine, and if I write it out at that point it writes out fine. And validate says it's good unicode. But later... valid = true, len = 1

Re: Decompressing bzip2

2016-04-04 Thread Mike Parker via Digitalmars-d-learn
On Monday, 4 April 2016 at 21:32:10 UTC, stunaep wrote: Can you please explain what the scope keyword does and if there scope was originally intended to be used primarily with classes in order to get deterministic destruction. It ensures the destructor of a class is called when the scope exi

Re: unicode confusion--An answer

2016-04-04 Thread Charles Hixson via Digitalmars-d-learn
I was writing my output to two different files. Only one of them was set to utf-8, the other must have been some other encoding, because when I set the encoding to utf-8 everything cleared up. On 04/04/2016 04:04 PM, Charles Hixson via Digitalmars-d-learn wrote: Well, at least I think that it'

Re: Possible bug in RVO?

2016-04-04 Thread Yuxuan Shui via Digitalmars-d-learn
On Monday, 4 April 2016 at 21:31:08 UTC, Ali Çehreli wrote: On 04/04/2016 09:36 AM, Anonymouse wrote: On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: [...] assert(x.aa.length > 0); // <-- boom [...] No idea myself but that's where it seems to go wrong. Looks like

Convert wchar* to wstring?

2016-04-04 Thread Thalamus via Digitalmars-d-learn
I'm sorry for this total newbie question, but for some reason this is eluding me. I must be overlooking something obvious, but I haven't been able to figure this out and haven't found anything helpful. I am invoking an entry point in a D DLL from C# (via extern (C)), and one of the parameters

Re: Convert wchar* to wstring?

2016-04-04 Thread tcak via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 01:21:55 UTC, Thalamus wrote: I'm sorry for this total newbie question, but for some reason this is eluding me. I must be overlooking something obvious, but I haven't been able to figure this out and haven't found anything helpful. I am invoking an entry point in a