Why?? (prog question)

Oliver Fromme olli at lurza.secnetix.de
Wed Apr 1 01:40:15 PDT 2009


Polytropon <freebsd at edvax.de> wrote:
 > FreeBSD defines additional exit codes to specify the reason for
 > exiting more precisely in /usr/include/sysexits.h - for your
 > example, exit(EX_USAGE); would be a good exit code.

Actually, no.  The purpose of the <sysexits.h> codes is for
communication between SMTP processes (e.g. between an MTA
such as sendmail and a delivery agent such as procmail), so
the MTA can determine the meaning (severity) of the error
and how to proceed.

The only standard exit codes for "normal" programs are
EXIT_SUCCESS and EXIT_FAILURE.  You should use these.

 > [where to put braces]
 > In fact, I'm sticking to the concept that only the highest level
 > of "code groupers" deserve a new line {: these are functions in
 > C and class methods in C++. Everything else has the { appended
 > (after a space) to the construct that causes the {. So if you find
 > a }, you only need to look up. It's obvious that a } is caused
 > by a {, but you want to know the construct that made it appear,
 > for example if(), while(), a struct definition or something similar.
 > With this concept at hand, looking up will make you find this
 > construct in question at the first glance.

Of course this is purely a matter of taste and personal
preference.  My preference is similar to yours, but my
main reasoon is to save space.  I think it is a ridiculous
waste of space if every third line consisted only of a
sole brace (opening or closing).  To my eye, such lines
that are almost empty break the natural structure of a
piece of source code.  I insert empty lines quite often
in order to group source lines logically, but brace lines
break that grouping visually.

That's probably one of the reasons why I like Python so
much:  There are no braces for source structuring at all.
This allows me to write very compact code _and_ structure
it logically at the same time, making it easily readable
and comprehensible.  Furthermore, Python gets rid of all
of the brace problems that C has, e.g. relating an "else"
to the wrong "if" when multiple "if" statements are nested,
and forgetting to add braces when you add a second line to
an "if" branch (unless you always use braces in C, even
when they're superfluous, but again that's a waste of
space and does not really improve readability).

I could go on for hours, but this is really off-topic now,
so we should take this to the -chat list (or to private
mail).

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"One of the main causes of the fall of the Roman Empire was that,
lacking zero, they had no way to indicate successful termination
of their C programs."
        -- Robert Firth


More information about the freebsd-questions mailing list