what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread ikod via Digitalmars-d-learn
Hello, what are the rules for @nogc inference? It looks like sometimes compiler can infer @nogc, but not in this simplest case: int x() { return 1; } void main() @nogc { x(); } Thanks!

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template.

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template. Well, the general "rule" is, if it's code that must be available to the compiler when it's called, the

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-16 Thread ikod via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:55:18 UTC, Steven Schveighoffer wrote: On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template. Well, the general "rule" is

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-16 Thread Alex via Digitalmars-d-learn
On Friday, 16 November 2018 at 10:25:26 UTC, ikod wrote: On Thursday, 15 November 2018 at 21:55:18 UTC, Steven Schveighoffer wrote: On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if a

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-16 Thread ikod via Digitalmars-d-learn
On Friday, 16 November 2018 at 12:12:12 UTC, Alex wrote: = This code compiles as long as `lazy` is commented out. But I'd like to have both lazy parameter and @nogc inferrence for `library_func` so that user is not locked to code @nogc or not.

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread ikod via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:55:18 UTC, Steven Schveighoffer wrote: On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template. Well, the general "rule" is

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 30 Nov 2018 20:41:03 +, ikod wrote: > I can't find the reason why nogc/nothrow can't be inferred in this case: > > class S(K,V) > { > auto get/*()*/(K a) { > return 0; > } > } > void main() @nogc nothrow { > S!(int, string) sia; > auto v = sia.get(1); > }

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread ikod via Digitalmars-d-learn
On Friday, 30 November 2018 at 21:03:06 UTC, Neia Neutuladh wrote: On Fri, 30 Nov 2018 20:41:03 +, ikod wrote: I can't find the reason why nogc/nothrow can't be inferred in this case: class S(K,V) { auto get/*()*/(K a) { return 0; } } void main() @nogc nothrow { S!(

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 30 Nov 2018 22:10:11 +, ikod wrote: > Thanks for explanation, got it. > > My case is actually > > interface I(K,V) > { > int get()(K); > } Interface functions must be abstract. Templated functions are implicitly final. Final things can't be abstract. If there's something about