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

Issue: DECLARE-TYPE-FREE (Version 1)



I decided to write this up since it has been discussed endlessly
without a formal proposal, and to make it clear that it is
independent of the pending DECLARATION-SCOPE issue.

Issue:         DECLARE-TYPE-FREE

References:    CLtL p.158

Category:      ADDITION

Edit history:  Version 1, 18-Sep-88, Moon

Problem description:

Most people interpret CLtL's phrase "(TYPE type var1 var2 ...) affects
only variable bindings" to mean that code such as the following is
not valid Common Lisp, because a type declaration can only be attached
to a binding, not used free.

  (if (and (typep x 'fixnum) (typep y 'fixnum))
      (locally (declare (fixnum x y))
        ...algorithm using x and y...)
      ...similar algorithm using x and y...)

Proposal (DECLARE-TYPE-FREE:ALLOW):

Change the phrase "affects only variable bindings" to "concerns variable
bindings."  Clarify that this makes the above program a valid program
and that this kind of declaration means the same thing as inserting
THE in every reference to the variable and every setq of the variable.

Rationale:

There is no reason to forbid this usage, and people have often asked
for it.

Current practice:

I don't know.

Cost to Implementors:

None, it is valid to ignore type declarations.

Cost to Users:

None, this is a compatible addition.

Cost of non-adoption:

Common Lisp will be less self-consistent.

Benefits:

The above example will not have to be written in the following silly way,
which only works if x and y are used read-only:

  (if (and (typep x 'fixnum) (typep y 'fixnum))
      (let ((x x) (y y))
        (declare (fixnum x y))
        ...algorithm using x and y...)
      ...similar algorithm using x and y...)

Esthetics:

Yes.

Discussion:

None.