DEV Community

Discussion on: Stop waving the wand of magic numbers

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I'm okay with a comment on the constant, but not where it is used. Sometimes numbers come from external calculations that are not done in the code. This is common for many formulas in math, science, finance, and graphics.

I've had comments before referring to the code used to calculate the constant. I did this when it was too costly to calculate each time.

Collapse
 
itr13 profile image
Mikael Klages

One feature I can't wait for more languages to implement, is compile time code execution. Then such costly functions could be visibly coded, but also not have to run each time the program is opened.

Thread Thread
 
mortoray profile image
edA‑qa mort‑ora‑y

Does anything other than C++ offer this now?

I've usually resorted to a pre-build step that modifies source files.

Thread Thread
 
itr13 profile image
Mikael Klages

I think I read that scala has it? Personally I'm pretty excited for JAI (though that might not be released for a few years), but that may be mostly suited for game-development rather than general programming and software.