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

Re: Proposal: Abstract types for OOC



Stewart Greenhill <greenhil@murdoch.edu.au> writes:

> [...]
> Abstract Type Declarations:
> 
> Both types and methods may be declared abstract using the ABSTRACT system
> flag. For example:
> 
> TYPE
>   (* Declaration of abstract type *)
> 
>   a* = RECORD [ABSTRACT]
>     x-, y- : REAL;
>   END;
> 
>   PROCEDURE [ABSTRACT] (VAR v : a) F * (x, y : REAL);
>   BEGIN
>   END F;

The BEGIN is optional here.  And the procedure flags are placed before
the procedure name.

  PROCEDURE (VAR v : a) [ABSTRACT] F * (x, y : REAL);
  END F;

Ok, I am jut being picky here.

> Questions:
> 
> Q1: Logically, an abstract method may redefine another abstract method. In
> practice, when would this be used?

Donno.  One could redefine the result type of the function (in
non-conformant mode).  This may be useful.

> Q2: How do we enable abstract types in the module header? More generally,
> how do we enable optional features in the compiler?
> 
> One way might be to have a kind of meta-import statement which specifies
> which system flags are to be enabled. For example,
> 
> MODULE Channel [IMPORT ABSTRACT];
> 
> or
> 
> MODULE WinApi [
>   IMPORT CSTRING, ALIGN1, ALIGN2, ALIGN4, UNION, UNTAGGED, NIL_COMPAT;
>   INTERFACE "Pascal"; 
>   LINK
>     LIB "kernel32";
>     LIB "user32";
>     LIB "gdi32"
>   END
> ];
> 
> Although its more complex, it might be nice to be able to group related
> flags together (eg. the alignment tags could be imported as
> ALIGNMENT).

System flag were intended as a mechanism to define non-standard
behaviour of objects defined in other languages.  Basically it is a
back-end hack.  The back-end defines what can appear in [...] and it
parses it without interference from the fron-ent.  An elaborate scheme
to import flag "capabilites" is overkill.

I would prefer a simple declaration like

  MODULE Foo [SYSFLAGS];

to enable all possible system flags for the scope of the module.
Which flags are actually supported is up to the back-end, of course.

-- mva