help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Working with constansts


From: Drew Adams
Subject: RE: Working with constansts
Date: Sun, 10 May 2009 10:02:42 -0700

> Why is it called a constant if its not enforced?

As the doc says (explicitly): to signal programmer *intention*. It lets human
readers of the code know that it is *intended* that no one and no code will
change the value. Think of it as a comment to that effect, if you like: "Do not
change this value."

Coding with clear signals of intention is helpful, and too often overlooked.
Conventional distinctions of intention among `defconst' vs `defvar'; `when' and
`unless' vs `if' and `cond' vs `and' and `or'; and so on can make a big
difference in code legibility. Which in turn eases maintenance and makes it less
error-prone.

Likewise, wrt names of functions, variables, etc.: good names help maintainers
and code borrowers. Likewise, comments - good ones. Likewise, indenting and
whitespace generally.

All of these things are for human readers of code only. You, like the Lisp
reader, can do without them if you like. YMMV.

[I knew an excellent (in individual terms) Lisp programmer back in the 80s who
never used any whitespace that wasn't strictly needed for the Lisp reader and
never commented any code. He (almost) never hit the Return key. Needless to say,
no one else could work with his code. He did use reasonable names, however, and
he didn't use the same conditional (e.g. `if' or `cond') everywhere. He coded in
the way that was easiest to him and that got the point across to the Lisp
reader.]

Perhaps you have another question:
Q. Why isn't it enforced?  A. Lisp.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]