enum functions

Salih Dincer salihdb at hotmail.com
Wed Jan 11 18:01:17 UTC 2023


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 be pretty confusing 
if it comes across as if by mistake, am I wrong?

```d
void main()
{
     enum foo : char { a = 'H', b = 'i' }
     enum bar() { return new foo; }

     import std.stdio;
     foreach(char f; [bar.a, bar.b])
         f.write;

     writeln; // Hi
}
```
I think this use of enums should be prohibited. So, can I get an 
answer about not being able to make a type inference? So I'm very 
curious about the second part of the my post.

Thanks...

SDN at 79



More information about the Digitalmars-d-learn mailing list