Re: enum functions

2023-01-11 Thread Ali Çehreli via Digitalmars-d-learn
bout not being able to make a type inference? So I'm very curious about > the second part of the my post. Before looking at your example, here is what I tested. The code proves that type inference is the same for 'auto' and 'enum' functions: auto foo(T)(T t) { return t; } enum bar(T)(T t)

Re: enum functions

2023-01-11 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 10 January 2023 at 12:55:34 UTC, Adam D Ruppe wrote: It means nothing. The keyword tells the parser a function is about to begin, which triggers return type inference (exactly the same as `auto`), but otherwise it is completely ignored. Sorry to give compelling examples but it can

Re: enum functions

2023-01-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/10/23 7:55 AM, Adam D Ruppe wrote: On Sunday, 8 January 2023 at 18:42:58 UTC, Salih Dincer wrote: I'm wondering 2 things; firstly, does having an enum mean there is no auto-return? Or could it be CTFE? It means nothing. The keyword tells the parser a function is about to begin, which

Re: enum functions

2023-01-11 Thread bauss via Digitalmars-d-learn
On Tuesday, 10 January 2023 at 12:55:34 UTC, Adam D Ruppe wrote: On Sunday, 8 January 2023 at 18:42:58 UTC, Salih Dincer wrote: I'm wondering 2 things; firstly, does having an enum mean there is no auto-return? Or could it be CTFE? It means nothing. The keyword tells the parser a function is

Re: enum functions

2023-01-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 8 January 2023 at 18:42:58 UTC, Salih Dincer wrote: I'm wondering 2 things; firstly, does having an enum mean there is no auto-return? Or could it be CTFE? It means nothing. The keyword tells the parser a function is about to begin, which triggers return type inference (exactly the

Re: enum functions

2023-01-09 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 8 January 2023 at 18:42:58 UTC, Salih Dincer wrote: I'm wondering 2 things; firstly, does having an enum mean there is no auto-return? Or could it be CTFE? Second, why is there no inference when I use an enum in one of the functions below? I'm still wondering  SDB@79

Re: enum functions

2023-01-08 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 8 January 2023 at 18:42:58 UTC, Salih Dincer wrote: I accidentally had a function like this: ```d enum oneHalf(T)(T i) {      return i >> 1;   } ``` Also it seemed odd to me that this could compile! SDB@79

enum functions

2023-01-08 Thread Salih Dincer via Digitalmars-d-learn
Aho, I accidentally had a function like this: ```d enum oneHalf(T)(T i) {      return i >> 1;   } ``` I'm wondering 2 things; firstly, does having an enum mean there is no auto-return? Or could it be CTFE? Second, why is there no inference when I use an enum in one of the

Re: enum functions

2014-06-21 Thread Andrej Mitrovic via Digitalmars-d-learn
On Saturday, June 21, 2014, Paul D Anderson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Does enum have any effect on functions? I think that's just a parser bug.

enum functions

2014-06-20 Thread Paul D Anderson via Digitalmars-d-learn
); } The spec says that enums are used to declare constants. I'm not sure what it means for a function to be constant. My guess would be that the value of the function is CTFE'd and that value is stored as if it were a manifest constant, but that's not what happens. The enum functions operate