comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: feedback asked on dab-decoder software in Ada
Date: Sat, 24 Sep 2016 23:27:55 +0200
Date: 2016-09-24T23:27:55+02:00	[thread overview]
Message-ID: <ns6r4i$4lr$1@dont-email.me> (raw)
In-Reply-To: <2d49e17f-c57e-451e-a506-96f963b3cf61@googlegroups.com>

On 24.09.16 20:38, jan van katwijk wrote:
> I looked into the abundant use of access types. In the front end (i.e. the ofdm processing part) some access varaibles could be eliminated and replaced by "normal" variables. In the backend, however, quite some dynamic choices determine which part of the program should be active (e.g. MP2 decoding or MP4 decoding).

I'm guessing only, not having looked closely, but just in case:
the way to specify dynamic choice of types etc. is by declaring
variables and parameters to be of type T'Class, similar to C++'s T&:

struct S {};
bool operator==(const S& left, const S& right) { return true; };

/// calling op `foo` for parameters of any type derived from T.
S f(const T& thing) {
    return thing->foo(1);
}

class T {
public:
   T() {}
   virtual S foo(int) const = 0;
};

/// T1, T2 types derived from T

int main() {
   T1 x = T1();
   T2 y = T2(4);
   return (f(x) == f(y));
}


package N is

    type S is record
       null;
    end record;

    type T is abstract tagged null record;

    function foo(thing: T; X : Natural) return S is abstract;

    -- T1, T2 types derived from T

end N;

with N;
-- calling op `foo` for parameters of any type derived from T.
function F(Thing: N.T'Class) return N.S is
begin
    return Thing.Foo(1);
end F;

with N, F;  use N;
function Main return Integer is
    X : T1;
    Y : T2 := Construct (4);
begin
    return Boolean'Pos (F(X) = F(Y));
end Main;


-- 
"HOTDOGS ARE NOT BOOKMARKS"
Springfield Elementary teaching staff


  reply	other threads:[~2016-09-24 21:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18  9:00 feedback asked on dab-decoder software in Ada jan van katwijk
2016-09-15  9:00 ` Jacob Sparre Andersen
2016-09-24 17:45   ` jan van katwijk
2016-09-24 18:38     ` jan van katwijk
2016-09-24 21:27       ` G.B. [this message]
2016-09-25 10:44         ` jan van katwijk
2016-09-25  9:04     ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox