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

(declare (type fixnum ---)) considered etc.



    Date: Wed, 23 Jul 1986  15:53 EDT
    From: Rob MacLachlan <RAM@C.CS.CMU.EDU>


	Almost every other language in the entire world has a "INTEGER"
    type which has an ill-defined, fixed precision.  If Common Lisp is
    going to have comparable performance to these languages when running
    on the same hardware, then it is going to have to be comparably
    inelegant.

This argument is somewhat confused.  There are two conflicting goals
being pursued by the CL community.  One is to have portable programs.
The other is to have good performance on the particular implementation
you're using.  There is no way to write programs which simultaneously
satisfy both goals.  The best we can do as language designers is to
provide mechanisms which allow both to be achieved.  Ideally, we can
provide a range of options to users so they can choose their own balance
between performance and portability.  As a service to our users, we can
help them understand how to achieve either goal.

What "INTEGER" originally meant (in Fortran, for example) was, "the
biggest precision available on the machine".  Recently C and other
languages modified that slightly to be, "a reasonably big precision
which is still reasonably fast and doesn't take up too much space."
Many languages, like Pascal, provide (in addition to the fuzzy,
machine-dependent precisions) user-specified ranges or precisions.
These allow portable programs to be written which will be optimized to
be as fast as they can be on the particular machine.

Common Lisp provides for both kinds of declarations.  What's different
is that CL type "INTEGER" is defined to be arbitrary precision -- a
concept that traditional languages don't have.  In those languages, you
don't get the option of truly portable programs.

I didn't say we shouldn't have type FIXNUM.  I said we should put it
somewhere where it would be obvious that programs using it are probably
not portable.

Programmers who declare objects of type FIXNUM are just being sloppy.
If their goal is to make portable, fast programs, they'll figure out
what the range really is and tell the compiler.  If the range can't be
figured out, then telling the compiler that it's a FIXNUM is lie.  (If
you don't care about portability and your program works, it's a
convenient lie.)  If you want the freedom to be sloppy, or you really
can't limit the range, you must either pay the price of reduced
performance or buy a machine which doesn't need declarations to get
performance.  [I never use type declarations in my CL programs.]