Foreach/opApply with @nogc

2014-08-24 Thread Stefan Frijters via Digitalmars-d-learn
Should this be possible? I admit to not being fully clear on the way delegates are handled, but maybe someone can shed some light? As an example I use a snippet Ali uses to demonstrate opApply: struct NumberRange { int begin; int end; int opApply(int delegate(ref int) @nogc operations)

Re: Foreach/opApply with @nogc

2014-08-24 Thread ketmar via Digitalmars-d-learn
On Sun, 24 Aug 2014 13:22:49 + Stefan Frijters via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: @nogc is a part of signature. gc-function can't call @nogc-one. the same is with calling @system function from @safe one, for example. or impure function from pure. so to say,

Re: Foreach/opApply with @nogc

2014-08-24 Thread bearophile via Digitalmars-d-learn
ketmar: there is currenly no way to specify attributes for such implicit delegates. It could be a nice language enhancement. Bye, bearophile

Re: Foreach/opApply with @nogc

2014-08-24 Thread ketmar via Digitalmars-d-learn
On Sun, 24 Aug 2014 13:58:45 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: there is currenly no way to specify attributes for such implicit delegates. It could be a nice language enhancement. i agree. but i tend not to fill enhancement requests without

Re: Foreach/opApply with @nogc

2014-08-24 Thread ketmar via Digitalmars-d-learn
On Sun, 24 Aug 2014 14:34:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: putting this information in Bugzilla is better than letting this get forgotten. so it can be forgotten in Bugzilla. ;-) signature.asc Description: PGP signature

Re: Foreach/opApply with @nogc

2014-08-24 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Aug 24, 2014 at 05:49:29PM +0300, ketmar via Digitalmars-d-learn wrote: On Sun, 24 Aug 2014 14:34:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: putting this information in Bugzilla is better than letting this get forgotten. so it can be

Re: Foreach/opApply with @nogc

2014-08-24 Thread bearophile via Digitalmars-d-learn
ketmar: so it can be forgotten in Bugzilla. ;-) And in ten, or one hundred or one thousand years the whole D language will be forgotten. There are various levels of remembering and forgetting. Putting bugs and ERs in databases is a different kind of forgetting. Bye, bearophile

Re: Foreach/opApply with @nogc

2014-08-24 Thread ketmar via Digitalmars-d-learn
On Sun, 24 Aug 2014 08:02:40 -0700 H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Some of us regularly comb through old bugzilla issues to find things to test fix. It may take a long time, but we do try. :-) (And we could use a lot of help -- there are only a

Re: Foreach/opApply with @nogc

2014-08-24 Thread Stefan Frijters via Digitalmars-d-learn
On Sunday, 24 August 2014 at 14:34:03 UTC, bearophile wrote: ketmar: but i tend not to fill enhancement requests without corresponding patches, I agree that having a patch ready is much better. But people like me file hundreds of ERs without too much damage done, and many of them get

Re: Foreach/opApply with @nogc

2014-08-24 Thread Ali Çehreli via Digitalmars-d-learn
On 08/24/2014 06:40 AM, ketmar via Digitalmars-d-learn wrote: On Sun, 24 Aug 2014 13:22:49 + Stefan Frijters via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: @nogc is a part of signature. gc-function can't call @nogc-one. the same is with calling @system function from

Re: Foreach/opApply with @nogc

2014-08-24 Thread ketmar via Digitalmars-d-learn
On Sun, 24 Aug 2014 11:45:14 -0700 Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Yeah, the only reason why the original code does not work is the write() expression in the foreach body. hm. really. i forgot what is delegate body for opApply. sure, here we can't

Re: Foreach/opApply with @nogc

2014-08-24 Thread Stefan Frijters via Digitalmars-d-learn
On Sunday, 24 August 2014 at 18:55:09 UTC, ketmar via Digitalmars-d-learn wrote: On Sun, 24 Aug 2014 11:45:14 -0700 Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Yeah, the only reason why the original code does not work is the write() expression in the foreach

Re: Foreach/opApply with @nogc

2014-08-24 Thread ketmar via Digitalmars-d-learn
On Sun, 24 Aug 2014 19:23:01 + Stefan Frijters via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: request I do have a followup question: is it possible somehow to have both a @nogc and a normal opApply function available? you can use templated opApply(): import std.traits;