www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - enum functions

reply "Paul D Anderson" <claude.rains msn.com> writes:
Does enum have any effect on functions?

Is this:

mixin (Constant!("ln2"));
package enum T ln2(T)(Context context) {
	return log(T.TWO, context, false);
}

different from this:

mixin (Constant!("ln2"));
package /*enum*/ T ln2(T)(Context context) {
	return log(T.TWO, context, false);
}

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 exactly like the non-enum 
functions.

So either enum functions are different in some way or they're 
not. If they are different that should be in the spec. If not, 
enum before a function declaration should not be allowed.

Paul
Jun 20 2014
parent Andrej Mitrovic via Digitalmars-d-learn writes:
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.
Jun 21 2014