[M3devel] alternate implementation of opaque types?

Rodney M. Bates rodney_bates at lcwb.coop
Sun Apr 7 17:48:57 CEST 2013



On 04/06/2013 04:59 PM, Jay K wrote:
> Is it conceivable/practical/possible/more-efficient to implement opaque types such that the "opaque" part is at the end instead of at the beginning?
>

This is neither an implementation nor a language design question, but a programmer's option.
The language allows private things before or after public, or more complicated combinations,
e.g., private, public, private.  In fact, arbitrary combinations are possible, although how
to put them together gets tricky and requires a lot of separate compilations.

Here is a public-private-public example that is, I think, believable:

INTERFACE Stack
; TYPE T <: Public
; TYPE Public = OBJECT METHODS
       push ( I : INTEGER )
       ...
     END (* Public *)
; END Stack .

(Module Stack is not shown.  It will have a revelation with private fields and overrides for push, etc. )

Later, somebody else wants to add:

INTERFACE StackWithStats
; IMPORT Stack
; TYPE T = Stack . T OBJECT
       PushCt : CARDINAL := 0
       ...
     OVERRIDES
       push := Push
       ...
     END (* T *)
; PROCEDURE Push ( s : T ; I : INTEGER )
; END StackWithStats .

MODULE StackWithStats
; PROCEDURE Push ( s : T ; I : INTEGER )
   = BEGIN
       INC ( s . PushCt )
     ; Stack . T . push ( s , I )
     END Push
...
; BEGIN END StackWithStats .

>
> We do suffer from the "fragile base type" problem either way, right?
> Currently when the opaque part changes size, we have to recompile all users of the transparent part, at least to generate new runtime type information that they all contain, right?
> Granted, that information should probably be single-instanced per type and accessed indirectly via a function call, possibly imported from the .dll/.so implementing the type.
>
>
> With my proposed change, you can recompile less actually. Though we probably wouldn't bother.
>
>
> As to knowing the size and being able to do a create, well, the size might be buried in the type information anyway, or a creating function exposed from where the full revelation is made.
>
>
>
>   - Jay




More information about the M3devel mailing list