enum functions

Paul D Anderson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 20 22:54:06 PDT 2014


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


More information about the Digitalmars-d-learn mailing list