From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,821f293084877cad,start X-Google-Attributes: gid103376,public From: Chris Papademetrious Subject: Adding a "Project Types" layer to a project Date: 1996/05/01 Message-ID: <3186E51C.250@post.drexel.edu>#1/1 X-Deja-AN: 152344422 content-type: text/plain; charset=us-ascii organization: Drexel University mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01Gold (Win95; I) Date: 1996-05-01T00:00:00+00:00 List-Id: I'm beginning a large project, and I'd like to base the entire project off base types defined in a package, as an extra layer of indirection for which I can change the underlying functionality later. The problem is, I'm having problems adding this level of indirection. Keep in mind I know very little about Ada 95, save for what I'm picking up here on the newsgroups and such... Here's what I have so far. Note that I want everything in the project to use ONLY the types defined in the package "types", which I can change to affect the entire project. This is the result I get when I try to compile this testcase: /home/chrispy/bot > gnatmake test gcc -c test.adb test.adb:20:20: invalid operand types for operator "+" gnatmake: *** compilation failed. If I use the type from the package "vectors" directly, it works. If I create a subtype in types, and then use that, it fails. What am I missing? Thanks in advance... - Chris ===== vectors.ads: package VECTORS is type VECTOR is array(integer range<>) of float ; function "+" (A : VECTOR; B : VECTOR) return VECTOR ; -- sum of vector end VECTORS; ===== vectors.adb: package body VECTORS is function "+" (A : VECTOR; B : VECTOR) return VECTOR is C : VECTOR(A'first..A'last) ; begin if A'first /= B'first or A'last /= B'last then raise INCOMPARABLE_DIMENSION; end if ; for I in A'range loop C(I) := A(I)+B(I) ; end loop ; return C ; end "+"; end VECTORS; ===== types.ads: with Vectors; package TYPES is subtype Distance is FLOAT; subtype Vector is Vectors.VECTOR; end TYPES; ===== test.adb: with Text_IO, Ada.Float_Text_IO, Ada.Integer_Text_IO; with Types; use Text_IO, Ada.Float_Text_IO, Ada.Integer_Text_IO; use Types; procedure test is distance1: Distance := 2.0; distance2: Distance := 3.0; point1: Vector := (1.1, 2.2); point2: Vector := (3.3, 4.4); begin distance1 := distance1 + distance2; point1 := point1 + point2; end;