COVER FE ATURE
compUteR
50
We can improve code quality without
adding runtime costs.
developers simply precomputed answers and added them
to the source code or as data inputs, which is rather ad
hoc. In C, compile-time computation implies a rat’s nest
of complicated and error-prone macros. Such computation
is essentially untyped because most information must be
encoded as integers. For infrastructure code, I suggest a
more systematic and structured approach: type-rich pro-
gramming at compile time.
7
The SI units example is an
illustration.
Compile-time evaluation (and immutability in general)
becomes more important as more systems become con-
current: You can’t have a data race on a constant.
Do'stlaringiz bilan baham: |