Problem with overloading in layered packages 
Author Message
 Problem with overloading in layered packages

I have a problem where I want to avoid overloading in more than one place in a
layered package structure.

Let's say I have two types that are declared identically (but still different):

  type UNSIGNED is array (INTEGER range <>) of BIT;
  type TWOSCOMP is array (INTEGER range <>) of BIT;

They are declared in the package PACK1 together with a bunch of procedures that
are overloaded with respect to UNSIGNED and TWOSCOMP:

  procedure Move1 ( L : UNSIGNED; O : out UNSIGNED);
  procedure Move1 ( L : TWOSCOMP; O : out UNSIGNED);
  procedure Move1 ( L : UNSIGNED; O : out TWOSCOMP);
  procedure Move1 ( L : TWOSCOMP; O : out TWOSCOMP);

Then I have another package, PACK2, that declares a number of procedures using
calls to procedures in PACK1. Do I really have to deal with overloading in PACK2
as well? Such as:

  procedure Move2 ( L : UNSIGNED; O : out UNSIGNED);
  procedure Move2 ( L : TWOSCOMP; O : out UNSIGNED);
  procedure Move2 ( L : UNSIGNED; O : out TWOSCOMP);
  procedure Move2 ( L : TWOSCOMP; O : out TWOSCOMP);

and in the body:

  procedure Move2 ( L : UNSIGNED; O : out UNSIGNED) is
  begin
    Move1 ( L, O);
  end;

  procedure Move2 ( L : TWOSCOMP; O : out UNSIGNED) is
  begin
    Move1 ( L, O);
  end;

and so on ...

Quote:
>> I'm talking a large number of procedures with more than two parameters! <<

As in the example above, all procedure bodies with the same name in PACK2 would
be IDENTICAL (albeit not this simple). Overloading COULD happen solely in PACK1.

My first idea for a solution was something like:

  type FIXPOINT is array (INTEGER range <>) of BIT;
  type TWOSCOMP is FXP;
  type UNSIGNED is FXP;

and define procedures in PACK2 on FIXPOINT:

  procedure Move2 ( L : FIXPOINT; O : out FIXPOINT);

This doesn't work (otherwise you wouldn't be reading this). I've also tried
subtypes, but they only provide a new name for the type, not a new type.

Is there any way I can avoid this tedious overloading?




Mon, 01 Nov 1993 06:38:27 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. layered packages

2. Package/subunit/overload question

3. layering canvases problem

4. Windows 2000 window stacking (layering) problem

5. Help: Tk widget layering problems

6. HELP! Envy Packaging Problem: Packaging Proxies

7. Problems with DNS package in TCLLIB and the TCLUDP package

8. C, , overloading problem? (was: CASE tools)

9. Haskell typing problems (Unresolved Overloading)

10. Problem when overloading a procedure

11. problem linking overloaded functions

12. Problems with Irix (stack overload)

 

 
Powered by phpBB® Forum Software