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,e5fae12a81834f90 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-22 03:04:42 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!EU.net!blackbush.xlink.net!newsfeed.germany.net!newsfeed2.easynews.net!easynews.net!news.cid.net!news.enyo.de!news1.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Re: AdaYY wish list from current projects Date: 22 Feb 2001 12:08:44 +0100 Organization: Enyo's not your organization Message-ID: <87u25nnfer.fsf@deneb.enyo.de> References: <96ulad$r9e$1@belenus.iks-jena.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Xref: supernews.google.com comp.lang.ada:5426 Date: 2001-02-22T12:08:44+01:00 List-Id: lutz@belenus.iks-jena.de (Lutz Donnerhacke) writes: > I have three sad problems (and a bonus problem) from my current projects. > If they can fixed by a compiler it would be very fine: > > Problem 1: Pointer of component => Pointer to aggregate > > In order to mixin a generic list with head nodes not mixed into any other > user defined structure I'd need to link not the base data but the mixin > itself. Doing so I need to regenerate the whole aggregate pointer from > a pointer of a component. Current (not tested) implementation: For limited types, there is another approach: generic type Base is tagged limited private; package Mix_In is type Mixed is new Base with private; type Mix_In_Type (Ref : access Mixed) is tagged limited private; type Mix_In_Access is access all Mix_In_Type'Class; function Cast (B : Mixed) return Mix_In_Access; private type Mix_In_Type (Ref : access Mixed) is tagged limited record null; end record; type Mixed is new Base with record Mix_In : aliased Mix_In_Type (Mixed'Access); end record; end Mix_In; package body Mix_In is function Cast (B : Mixed) return Mix_In_Access is begin return B.Mix_In.Ref.Mix_In'Access; end Cast; end Mix_In; It appears that Ada is not suitable for this kind of design. > Problem 2: Defining Byte_Order of record representations > > My low level networking application has to deal with low and big endian > values on the net I want to handle with record representations clauses > in order to get the benefits of compiler generated I/O functions. For my OpenPGP implementation, I've written my own stream I/O functions. That's certainly the way to go if you don't need a specific in-memory representation. I don't think an additional attribute is really necessary. Instead, vendors could provide packages like Interfaces.Little_Endian and Interfaces.Big_Endian which contain the Integer_* and Unsigned_* types from package Interfaces, with the corresponding in-memory and stream representation. If you make these types private and provide conversion functions, you can implement these packages even yourself. > Problem 3: Static expressions of discriminants in record representations > > Trying to may a simple data structure like a Pascal string is not possible > with Ada95. The following seems to work in some cases. subtype Pascal_Length is Integer range 0 .. 255; type Pascal_String (Length : Pascal_Length) is record Data : String (1 .. Length); end record; pragma Pack (Pascal_String);