if the else short form

John Nagle nagle at animats.com
Wed Oct 13 19:25:28 CEST 2010

On 10/10/2010 6:46 PM, Lawrence D'Oliveiro wrote:

> Languages that insisted on being able to do proper compiler-level cross
> checks between separately-compiled modules (e.g. Modula-2, Ada) never really
> became that popular. This saddened me.

    It's an sad consequence of a UNIX mindset that "you can't change
the linker".  This stems from the early days of UNIX, where the
linker was in assembler, very limited, and had very few
comments.  That's why C++ had "name mangling", instead of
a type-aware linker.  Really.

    There are interesting things to do at link time, and the Gnu
toolchain finally added some of them.  Weak links, for example -
ones which are resolved if the target is present, but won't
pull it in. This allows bringing in C++ classes without
hauling in every unreferenced member function of the class.

    Modula did more at link time.  In Modula, modules had
initialization sections.  Initialization sections could call
functions in other modules.   The rule was that you couldn't call
into a module until the module's initialization section had run.
Conveniently, the Modula "binder" computed the dependency graph
of what called what, and ordered the initialization sections so
that all modules were initialized before being called.  The
binder could detect dependency loops, and reported them at
link time.  So if the program would build, it would initialize
in proper order.

    This is a nice check, because it's a global property of
the program, not a local bug.  It's the sort of thing that
appears on large projects where different people are doing
different modules.  Computers are better than
people at finding that class of problem.

    C++ got this wrong, leading to the "static initialization
order fiasco".  Python is vulnerable to this problem in
import loops, although the consequences aren't as severe as
in C++.

				John Nagle

More information about the Python-list mailing list