Cleanup Issue DECLARE-TYPE-EXACT

Category
ADDITION
References
type, ftype declaration specifier, pp. 158-159 THE special form pp. 161-162

Problem Description

Currently, it is not possible to declare that a particular variable be bound to a particular type and no subtype. Without the Common Lisp Object System, the lack of such a declaration is not particularly a problem; however, with CLOS, compiler writers may not be able to optimize out method lookup at compile time, if the class of a CLOS object or a DEFSTRUCT (called "user defined classes" for purposes of this proposal) cannot be exactly determined at compile time.

Proposal

(Font Note: UPPERCASE indicates bold, _this_ indicates italic)

EXACT-CLASS _class-specifier_ _var1_ _var2_ ... ) affects only variable bindings and specifies that the variables mentioned will take on values only of the specified user defined class, and no other. In particular, _vari_ is of exact class _class-specifier_ if, letting _subclass-specifier(j)_ be a subclass of _class_specifier_, then, for all _j_, (SUBTYPEP _vari_ _subclass-specifier(j)_) is false. It is an error if _class-specifier_ specifies an instance of STANDARD-TYPE-CLASS.

Rationale

Compiler writers may want a way of optimizing out method lookup at compile time for the Common Lisp Object System.

Current Practice

There is currently no way to specify that subtyping of variables is not allowed.

Adoption Cost

Difficult to judge. Will depend on the particular implementation, and should be part of implementing CLOS. Should not impact currently existing code, because built-in Common Lisp types are specifically excluded.

Cost of Non-Adoption

Determination of whether in-line insertion of method functions at compile time is permissible will require considerably more effort.

Benefits

Common Lisp Object System code can be optimized better.

Conversion Cost

Probably low, since it could be phased in as part of the Common Lisp Object System.

Discussion

Masinter:

> I'm reluctant to deal with EXACT-CLASS in CL-CLEANUP since it makes no > sense outside of CLOS. (This wasn't true of TRACE-FUNCTION-ONLY where > there were other kinds of things to trace and CLOS just was a good > motivation.)

Kempf: The original idea was to include built-in types as well, but there was some resistence to this, based on the fact that some implementations may subtype automatically, and the subtype may not be structurally equivalent. An example is using cdr-coding for a list. While I believe that operator equivalence is the more appropriate criterion, and hence such automatic subtyping should not be a problem, the concensus seemed to be to restrict EXACT-CLASS to user defined types, including DEFSTRUCTs. At the September meeting, we considered if there were any built-in types for which declaring something EXACT-CLASS could make a difference, and the conclusion was no, I believe. With CLOS, of course, it would allow insertion of a method whose discriminators were built-in, but without CLOS, it would not make a difference, except for DEFSTRUCTs.

In addition, the objects committee also seemed to believe this was a clean-up issue. I fear it may get lost between the two, however, I'll bring it up again in November.

jak

Edit History