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

Category Errors

One minor point that came up at the Symbolics meeting last Thursday
was category errors and whether we should try to outlaw them somehow.
Here is an example of a category error:

Suppose that MAKE-INSTANCE is a generic function. Its definition
might look like this:

	(defmethod make-instance ((class standard-class) &rest args)...)

Notice that the class of the argument CLASS is STANDARD-CLASS, which
indicates that the operation of MAKE-INSTANCE is controlled at the
meta-object level. Suppose someone were to write:

	(defmethod make-instance ((class apple-pie) &rest args)...)

	(make-instance (class-prototype (class-named 'apple-pie)) ...)

Here someone would be making a category error by defining a method on
MAKE-INSTANCE at the wrong level - the class level. What makes this easy
for a programmer to do this is the availability of CLASS-PROTOTYPE.
However, it is never hard to do because the programmer can write:

	(defvar *apple-pie-prototype* (make-instance 'apple-pie))

to get his class prototype. 

We have two alternatives:

	1. Let sea of classes/metaclasses remain a miasma and inform
	   programmer that he ought not mix things up.

	2. Define a notion of class category or classs level and have a
	   category of generic function for each class category.