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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b5ab7c96b188b59e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-15 00:43:27 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-atanamir.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: The "()" operator revisited. Date: Thu, 15 Jan 2004 09:50:16 +0100 Message-ID: <9ojc00dr0nehitt23o7adh43sc7acujio0@4ax.com> References: <3cga00pecuc18o3irdnmoin4e7ekh87n76@4ax.com> NNTP-Posting-Host: tar-atanamir.cbb-automation.de (212.79.194.116) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1074156206 14576558 212.79.194.116 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:4427 Date: 2004-01-15T09:50:16+01:00 List-Id: On Thu, 15 Jan 2004 01:21:16 +0000 (UTC), Georg Bauhaus wrote: >Dmitry A. Kazakov wrote: >: >: Templates are for generic programming. I would like to do generic >: programming in terms class-wide subroutines and discriminated types. > >Hm. How do you know then that you get an Apple from some Set, and >not an Orange? Is there a run time penalty? Which one? Templates do it at compile time anyway, so the type tags are statically known. The issue is whether tags and tag checks could be optimized out. This is why I do not like Ada functions, and want to have them pure. It should be possible to *require* a function evaluation at compile time. However, for specialized arrays three things atually required: 1. array discriminants 2. viewing type tag as a discriminant of a class-wide 3. placing tags and discriminants separately from the object body when known (same as with array bounds) Having these things one could just write: type Fruit is ...; type Fruit_Array (Kind_Of : Tag) is array (...) of Fruit'Class (Kind_Of); If you have Apples and Oranges, then: type Apple is new Fruit with ...; subtype Apple_Array is Fruit_Array (Apple'Tag); type Orange is new Fruit with ...; subtype Orange_Array is Fruit_Array (Orange'Tag); -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de