"enum" in function declaration

Timon Gehr timon.gehr at gmx.ch
Sun May 29 12:48:10 PDT 2011


Currently, DMD accepts declarations of the form:

enum int foo(){writeln("foo!\n");return 123;}

which seems to be exactly equivalent to

int foo(){writeln("foo!\n");return 123;}

However, enum foo(){writeln("foo!\n");return 123;} is rejected.

Given the fact that enum is also used for declaring manifest constants, this
does seem odd. No semantic implications are added to a function declaration
when extended by the enum storage class.

I see two possibilities:

1. Disallow "enum" functions.
2. Allow, and make the "enum" function compile-time only.


Timon


More information about the Digitalmars-d mailing list