|
Home
>
3. concept
>
3.3 types and classes
>
3.3.1 types
>
3.3.1.4 instantiable types
>
3.3.1.4.1 What types are instantiable?
|
Previous
Next
|
|
|
|
|
|
Paul Haahr
|
``Instantiable type'' : [...] The unifying concept is that all ``instantiable
types'' are types which can be instantiated.
The rule specified in the DIRM is that make may be called on
``instantiable types,'' of which there are two defined by the language:
classes and limited collections. (The latter may be implemented as
classes, according to the design note.)
Note, by the way, that not all classes are instantiable types.
Abstract classes are by default not instantiable. And, by defining a
make method I can switch the classification for a particular type.
|
|
Jeff Dalton
|
What do they have in common apart from that? Why are they, and
they alone, instantiable?
|
|
Paul Haahr
|
The rule is:
The first argument to make must be an instantiable
type.
The definition is:
An instantiable type is a type suitable for use as
an argument to make.
I don't mind living with the circularity, but one of the reasons that it's
hard to pin down is that you can change what's instantiable by
defining methods on make.
If you want a set of rules, here's a set off the top of my head.
- Most concrete classes are instantiable, but you can
change this by defining a make method which signals an
error. Some builtin concrete classes, notably those with
special behavior for the == function (e.g., numbers), are
not instantiable.
- Abstract class are not instantiable unless there is a make
method. It is common among the builtin abstract classes
for there to be a make method which instantiates a
subclass of the abstract class.
- Limited collection types are instantiable, though redefining
a make method might interfere with this.
- Other types are generally not instantiable, though a make
method can probably change this.
The important idea here, to my mind, is that instantiability is purely
an operational aspect of make's behavior. It is not a property of the
type system.
|
|
|
|
|
|