From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: AdaYY wish list from current projects
Date: 22 Feb 2001 12:08:44 +0100
Date: 2001-02-22T12:08:44+01:00 [thread overview]
Message-ID: <87u25nnfer.fsf@deneb.enyo.de> (raw)
In-Reply-To: 96ulad$r9e$1@belenus.iks-jena.de
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);
next prev parent reply other threads:[~2001-02-22 11:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-20 20:50 AdaYY wish list from current projects Lutz Donnerhacke
2001-02-22 11:08 ` Florian Weimer [this message]
2001-02-22 13:02 ` Lutz Donnerhacke
2001-02-23 9:30 ` Florian Weimer
2001-02-23 10:12 ` Lutz Donnerhacke
2001-02-23 13:54 ` Florian Weimer
2001-02-23 14:16 ` Lutz Donnerhacke
2001-02-23 15:04 ` Florian Weimer
2001-02-23 15:15 ` Lutz Donnerhacke
2001-02-23 16:21 ` Florian Weimer
2001-02-23 16:31 ` Lutz Donnerhacke
2001-02-23 17:25 ` Florian Weimer
2001-02-26 11:22 ` Lutz Donnerhacke
2001-02-23 19:06 ` tmoran
2001-02-26 11:20 ` Lutz Donnerhacke
2001-02-23 19:06 ` tmoran
2001-02-26 11:21 ` Lutz Donnerhacke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox