Re: OO Style with Ada Containers



On Nov 24, 1:46 am, Pascal Obry <pas...@xxxxxxxx> wrote:
braver a écrit :

Very ineteresting -- Matt, can you pls elucidate these idioms below?

On Nov 19, 5:24 am, Matthew Heaney <matthewjhea...@xxxxxxxxxxxxx>
wrote:

type Scanner (<>) is tagged limited private;

What does (<>) say here -- that the type is unconstrained?

Yes. Scanner has a privately defined discriminant. So the public view of
Scanner must be declared unconstrained.

private

type Handle (S : not null access Scanner) is limited null record;

type Scanner (Last : Natural) is tagged limited record
H : Handle (Scanner'Access);
Line : String (1 .. Last);
Word_First : Positive;
Word_Last : Natural;
end record;

What's the logic behind the definition and usage of the Handle H
throughout?

It is for gaining write access to function in parameter. A simpler
solution is:

type Scanner (Last : Natural) is tagged limited record
Self : access Scanner := Scanner'Unchecked_Access;
Line : String (1 .. Last);
Word_First : Positive;
Word_Last : Natural;
end record;

Ah. Didn't see H assigned -- in this case, Scanner'Access with the
type name means the address of the actual parent type record instance?

So basically to simplify even further, we'd just have procedures with
honest in out parameters?

Cheers,
Alexy
.