comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generic Library Units?
Date: Mon, 13 Oct 2014 09:45:01 +0200
Date: 2014-10-13T09:45:01+02:00	[thread overview]
Message-ID: <j461ib3fvao8.djsu7d5i2elo$.dlg@40tude.net> (raw)
In-Reply-To: ca0e9mFdl2vU1@mid.individual.net

On Sun, 12 Oct 2014 19:39:49 -0300, hreba wrote:

> On 10/12/2014 12:47 PM, Dmitry A. Kazakov wrote:
>> On Sun, 12 Oct 2014 11:38:16 -0300, hreba wrote:
>>
>> A child of a generic package must be generic. I.e. you should declare it
>> this way:
>>
>> generic
>> package GuiGtk.SimpleGad is
> 
> Did that. And I added to Gui.ads the line
> 
>     with package TKSG is new GuiGtk.SimpleGad;
> 
> Now the line in mainaux.ads:
> 
>     package GuiTK is new Gui(Toolkit);
> 
> which was correct before, is accused:
> 
> mainaux.ads:10:04: missing actual "TKSG"
> mainaux.ads:10:04: in instantiation of "Gui" declared at gui.ads:13
> 
> Adding
>     package ToolkitSG is new GuiGtk.SimpleGad;
> before that line gets me
> mainaux.ads:9:29: invalid prefix in selected component "GuiGtk"
> 
> Replacing it with
>     package ToolkitSG is new Toolkit.SimpleGad;
> turns the error message into
> mainaux.ads:9:36: generic child unit "SimpleGad" is not visible
> 
> So how do I instantiate that?

with Gui;
with GuiGtk.SimpleGad;
with Gui.SimpleGad;
package MainAux is
    package Toolkit is new GuiGtk;
    package SimpleGad is new Toolkit.SimpleGad;
    package GuiTK is new Gui (Toolkit, SimpleGad);
end MainAux;

>> And you will have to instantiate it somewhere.
>>
>> Generic packages are not suitable for abstraction GUI engines as complex as
>> GTK or Qt. If you really want to use both GTK and Qt as the back-end, you
>> should carefully design a set of abstract tagged types in several packages.
>> GTK and Qt versions will derive from theses types.
>>
> I don't want to mix different toolkits. I want to have the same API in 
> the case I switch to another one later.

It does not matter. You have to design these "same API" in one way or
another. Doing this in the form of generic packages, when API's basic
operations are formal generic subprograms and the rest is implemented in
these terms is extremely tedious for anything more complex than trivial
teaching examples.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2014-10-13  7:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-12 14:38 Generic Library Units? hreba
2014-10-12 15:47 ` Dmitry A. Kazakov
2014-10-12 22:39   ` hreba
2014-10-13  7:45     ` Dmitry A. Kazakov [this message]
2014-10-15  0:29       ` hreba
2014-10-15  7:21         ` Dmitry A. Kazakov
2014-10-16  1:21           ` hreba
2014-10-16  7:04             ` Dmitry A. Kazakov
2014-10-16  7:54             ` Simon Wright
2014-10-17 12:46               ` hreba
2014-10-16 10:36           ` AdaMagica
2014-10-17 12:57             ` hreba
replies disabled

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