Do we really need const?

Ingo Oeser ioe-news at rameria.de
Mon Sep 24 13:54:05 PDT 2007


Robert Fraser wrote:

> But should language features be added to maker reading code easier?

Yes. Many projects use domain specific languages to make the code more
readable. Very common are table generators.

The Linux kernel project uses several enhancements to support checkers
while improving readability.

One example is endian annotation. You often get data from the
network or through some hardware in a specific endianess.

You only have to convert that when you start calculating with that stuff
or try to hand it out to user space with an API which is defined 
in native byte order. Since in some networking situations
most received stuff can be dropped (e.g. firewall in extremely unfriendly
environment), it is wise to defer endian conversion to latest possible.

To get all the situations right where we handle native or network 
byte order, the structure members and function arguments are endian 
annotated.

Now you just need to look at the function signature to get it right.
Or run a static checker (like sparse) to check correctness.

But really, that stuff is like medicine: The dose matters :-)


Best Regards

Ingo Oeser



More information about the Digitalmars-d mailing list