A recent posting that expressed a desire for #ifdef struck
me as perverse.  A prime reason for using Haskell is its
elegance and clarity.  To adopt the most inelegant and
turgid feature from C would be like encouraging graffiti
in a museum.

Most #ifdef's and #if's memorialize failures of imagination
or care, often in the name of "portability".  Code is
NOT portable if it has to be rewritten according to the
conventions of each environment.  Ifdef expresses just such
rewriting, and in an egregious style: it inverts the
logical structure of a program, bringing the tweaks to
the top while fragmenting the real architecture.

To make code portable, one should first get rid of system
dependencies to the greatest extent possible.  Then treat
the recalcitrant residue with the same sense of style as
any other programming task.

Some standard methods that apply everywhere in programming
are equally helpful for portability:

   Modularization (sweeping systemisms into a corner)
   Generalization (rising above the systemisms)

For dealing with the recalcitrant residue, a method that
Haskellites should find specially sympathetic is

    Specialization (freezing certain parameter values)

Ifdef, if course, is a specialization technique, but from
another era.  If there really is a need for specialization,
it would be far better to employ a Ershovian specializer
that creates Haskell from Haskell rather than from
stone-age idioms.  Is one available?

Doug McIlroy
Hugs-Users mailing list

Reply via email to