[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Abstract classes in Oberon / OOC
Stewart Greenhill <greenhil@murdoch.edu.au> writes:
> Component Pascal introduced the ABSTRACT keyword for method and class
> declarations. If a method is tagged ABSTRACT, it is allowed to be
> unimplemented (ie. no procedure body is specified). If a class is tagged
> ABSTRACT, it is allowed to have abstract methods. An abstract class can
> never be instantiated. There are a couple of subtleties that aren't
> implemented properly, but on the whole Component Pascal gives a BIG safety
> improvement in this respect.
What are the "subtleties" that aren't implemented properly?
> Would it be possible to add something like this to OOC? Here are two
> possibilities:
>
> 1) Allow [ABSTRACT] tags to be used on RECORD and PROCEDURE declarations.
> For ABSTRACT procedures the body is ignored if specified.
> -- OR --
> 2) Interpret a procedure with a single HALT(abstractMethod) statement as an
> abstract method.
>
> Neither of these options requires a change to the syntax of the language.
> They do allow the programmer to better inform to the compiler about what is
> intended, and for the compiler to check that no unintended mistakes are
> made. Approach (2) has the disadvantage of only allowing abstract methods
> to be declared, not abstract classes. For the compiler to properly check
> that you have implemented all abstract methods, it needs to know whether
> you intend to declare an abstract or concrete class. Therefore, (1) is my
> preferred approach.
Version 2 has little appeal. I would only support version 1 if any
system flags "[...]" are _only_ permitted if this is explicitly
requested in the module header. Previously oo2c disallowed system
flags altogether in standard modules (i.e., modules that are neiter
INTERFACE nor FOREIGN), currently oo2c permits them anywhere so we can
evaluate the necessary extensions for the Win32 API.
> Comments? Language purists: please don't flame me too hard :-)
Note that making with making it a system flag issue, this is an OOC
specific extension. Technically we are not touching the O2 syntax,
but we do change O2 semantics by disallowing instanciation of certain
user defined types.
-- mva