Runtime constant definitions
Lars Kyllingstad
public at kyllingen.NOSPAMnet
Thu Sep 11 23:14:13 PDT 2008
Hi,
I'm trying to define a couple of constants that I want to be computed at
run time. I have written the following code:
---
/// Square root of real-number precision.
final real REAL_EPSILON_SQRT;
/// Cube root of real-number precision.
final real REAL_EPSILON_CBRT;
static this()
{
REAL_EPSILON_SQRT = sqrt(real.epsilon);
REAL_EPSILON_CBRT = cbrt(real.epsilon);
}
---
Compiling this, I get the errors
scid/core.d:21: Error: cannot modify final variable 'REAL_EPSILON_SQRT'
scid/core.d:22: Error: cannot modify final variable 'REAL_EPSILON_CBRT'
where the lines 21 and 22 are the ones inside the curly braces. What's
wrong?
Thanks,
Lars
More information about the Digitalmars-d-learn
mailing list