TYPE-DECLARATION-ABBREVIATIONTYPE declaration abbreviation, the ability to write (DECLARE (<type-specifier> <var> <var>...)) in place of (DECLARE (TYPE <type-specifier> <var> <var>...)) is allowed only for some <type-specifier>s, not for all of them.
CLtL allows the abbreviation only when <type-specifier> is a symbol and not a user-defined or implementation-defined type.
The draft ANSI CL specification is unclear since it refers to the wrong table. If it really meant to refer to Figure 2-11 rather than 2-10, then it says the same thing as CLtL, assuming the mistakes in Figure 2-11 get corrected (e.g. standard-generic-function is missing).
This makes a distinction between type specifiers specified by the language standard and type specifiers defined by the user or by the implementation. Do programmers have to know whether types they use come from the kernel language or from a library in order to know whether they are allowed to use abbreviated type declarations? Do they have to refer to this table that currently contains 91 entries and is still growing?
This also makes an unnecessary distinction between type specifiers that are symbols and those that are lists or classes.
This issue contains two proposals.
This is Symbolics issue #31 and is related to Loosemore's issue #8 of 27 Feb 90.
TYPE to be omitted from all TYPE declarations.
A symbol cannot be both the name of a type and the name of a declaration. Defining a symbol as a class, structure, condition, or type name, when the symbol has been defined or proclaimed as a declaration name, or vice versa, signals an error.
DEFUN SUBSTRING (STRING &OPTIONAL (START 0) END) (DECLARE (STRING STRING) ((INTEGER 0 *) START) ((OR NULL (INTEGER 0 *)) END)) (SUBSEQ STRING START END))
(DEFSTRUCT SHIP HEADING TONNAGE PASSENGER-LIST)
(DEFUN EMBARK (P S) (DECLARE (SHIP S)) (PUSHNEW P (SHIP-PASSENGER-LIST S)))
(DEFCLASS ASTRONAUT () (HELMET-SIZE FAVORITE-BEVERAGE))
(DEFUN CHECKOUT (A) (DECLARE (#.(FIND-CLASS 'ASTRONAUT) A)) (UNLESS (EQ (SLOT-VALUE A 'FAVORITE-BEVERAGE) 'TANG) (ERROR "~A is not a proper astronaut" A)))
Making type names and declaration names be a single namespace eliminates any issue of ambiguity in interpreting a decl-spec.
TYPE to be omitted from any TYPE declarations. This would be an incompatible change.
Cost to Implementors of ALLOW-ALL:
Small. It should be easy to change the declaration parser to check whether the car of a decl-spec is a valid type-specifier, and if so either insert the word TYPE or signal an error, depending on whether it's also a proclaimed declaration.
Cost to Users of ALLOW-ALL:
None to most users. Some users might have programs that use the same symbol as both a declaration name and a type name, and they would have to rename either the declaration or the type.
Implementors will continue to have to maintain a large and seemingly ever-changing table of type names that are acceptable as declarations.
Another possible approach would be to eliminate type declaration abbreviation, however no one liked that idea when it was mentioned a few months ago.
David Gray is opposed to allowing abbreviation for all types on the grounds that infrequently-used types might not be recognized as types by someone reading a program. Asked for suggestions, he said:
Well, if I had to be limited to twelve, I would choose:
ARRAY CHARACTER CONS FIXNUM FLOAT INTEGER LIST NUMBER STREAM STRING SYMBOL VECTOR
but I suspect that this small a list would be too much of an incompatibility to be acceptable since other people are sure to have a different favorite twelve. It might be possible to agree on a list of around twenty, such as:
ARRAY BIT BIT-VECTOR CHARACTER COMPLEX CONS FIXNUM FLOAT INTEGER KEYWORD LIST NUMBER PACKAGE PATHNAME REAL SEQUENCE STREAM STRING SYMBOL VECTOR
David Moon prefers not to single out some types as special cases.
Glenn Burke is not entirely comfortable with the proposal, but doesn't like restricting programmers' use of data-abstraction by singling out some types as special cases.
Kim Barrett is concerned that signalling an error when there is a collision between a type name and a declaration name doesn't really solve the problem.