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

Possible changes to abstract types proposal



Folks,

Here are some points that have been raised in the discussion about my
abstract types proposal. I don't want to get too involved in deep
philosophical discussions about this. However, I would welcome any opinion
on the questions outlined below. If there is a strong opinion one way or
the other, I will change the specification to reflect this opinion. This
will depend on how you view the pros and cons listed below, and whether you
believe it is desirable to:
- allow abstract types that do not have abstract methods.
- allow abstract extensions of concrete types.

(Q1) Should abstract records be explicitly declared ABSTRACT?

The current proposal requires abstract records to be explicitly declared
ABSTRACT. This information can be used by the compiler for early detection
of certain errors. For example, a concrete class must implement inherited
abstract methods. With explicit declaration, the error is reported in the
module that declares the class. Without explicit declaration, all classes
with abstract methods are assumed to be abstract and errors will not appear
until later when the programmer attempts to instantiate the class (thereby
implying that it is concrete). Explicit declaration is used in Component
Pascal and Java. Implicit declaration is used in C++.

Pros:
- Provides documentation. Improves clarity of declarations. 
- Allows early catching of errors.
- Necessary to allow declaration of abstract types that do not have
abstract methods.

Cons:
- Requires explicit declarations for record types.
- May require multiple changes to classes if a base class changes its
"abstractness".
- Can lead to some potentially confusing declarations (eg. abstract types
that do not have abstract methods).

(Q2) Should it be possible to declare abstract extensions of concrete types?

The current proposal does not allow concrete types to have abstract
extensions. There is no technical reason for this restriction that I can
think of. There may be philosophical arguments related to the desirability
of implementation inheritance. Both Java and C++ allow abstraction of
concrete types. Component Pascal does not.

Pros:
- Simpler specification (no restriction on abstract extensions).
- Allows abstract types to inherit implementation from concrete types.

Cons:
- Use of this feature may lead to implementation dependences between
classes and descendents. May result in unstructured class hierarchies.

Please reply to the list if you have a comment. Alternatively, just mail me
with your vote and I'll post a summary later.

Thanks,

- Stewart