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: 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: 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 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 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

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