comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Containers warnings with gnat
@ 2014-11-15 14:35 Björn Lundin
  2014-11-15 15:15 ` Björn Lundin
  2014-11-15 18:01 ` Jeffrey Carter
  0 siblings, 2 replies; 9+ messages in thread
From: Björn Lundin @ 2014-11-15 14:35 UTC (permalink / raw)



Hi!
I'm using a db to keep data in, that I retrieve and
put into ordered and hashed maps from Ada.Containers.

I do this to
 * learn to use Ada standard containers, instead of home-rolled lists
 * to simulate outcome of different parameters into a business modell

Reading from db takes about 1 hour, with i5/ssd/12 gb ram
needless to say, I'd like this to go faster.

So, I rewrote the simulator to use the mentioned containers.
I then run it once, and save the maps into (largish ) files
instead via streams and 'write/'read.

fantastic performance.

The simulator was in a single file before -> no problem.
So I then refactored and created a storage package and suddenly I get
warnings like

 /home/bnl/bnlbot/botstart/bot-1-0/source/ada/local/utils/simulation_storage.ads
    17.   package Sample_Map_Pack is new Ada.Containers.Ordered_Maps
          |
        >>> warning: in instantiation at a-coorma.ads:266
        >>> warning: no entities of package "Ada.Streams" are referenced

    23.   package Marketid_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced

    30.   package Winner_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced

    37.   package Win_Place_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced



what do the mean ?
The body of the package uses streams like

    Log("read Marketid_Map from file ");
    declare
     File   : Ada.Streams.Stream_IO.File_Type;
     Stream : Ada.Streams.Stream_IO.Stream_Access;
     Filename : String := Map_files(Marketid).Filename.Fix_String;
    begin
      Ada.Streams.Stream_IO.Open
          (File => File,
           Name => Filename,
           Mode => Ada.Streams.Stream_IO.In_File);
      Stream := Ada.Streams.Stream_IO.Stream (File);
      Marketid_Map_Pack.Map'Read(Stream, Marketid_Map);
      Ada.Streams.Stream_IO.Close(File);
      Log("Marketid_Map read from file " & Filename);
    end;




package spec is

---------------------------
with Ada;
with Ada.Strings;
with Ada.Strings.Hash;

with Ada.Containers;
with Ada.Containers.Hashed_Maps;
with Ada.Containers.Ordered_Maps;

with Calendar2;
with Bot_Types; use Bot_Types;
with Table_Apricesfinish;
with Table_Arunners;

package Simulation_Storage is

  package Sample_Map_Pack is new Ada.Containers.Ordered_Maps
        (Key_Type     => Calendar2.Time_Type,
         Element_Type => Table_Apricesfinish.Apricesfinish_List_Pack2.List,
         "<"          => Calendar2."<",
         "="          => Table_Apricesfinish.Apricesfinish_List_Pack2."=");

  package Marketid_Map_Pack is new Ada.Containers.Hashed_Maps
        (Market_Id_Type,
         Sample_Map_Pack.Map,
         Ada.Strings.Hash,
         "=",
         Sample_Map_Pack."=");

  package Winner_Map_Pack is new Ada.Containers.Hashed_Maps
        (Market_Id_Type,
         Table_Arunners.Arunners_List_Pack2.List,
         Ada.Strings.Hash,
         "=",
         Table_Arunners.Arunners_List_Pack2."=");

  package Win_Place_Map_Pack is new Ada.Containers.Hashed_Maps
        (Market_Id_Type,
         Market_Id_Type,
         Ada.Strings.Hash,
         "=",
         "=");


  procedure Create_Files_From_Database;
  procedure Fill_Maps(Marketid_Map  : out Marketid_Map_Pack.Map;
                      Winner_Map    : out Winner_Map_Pack.Map;
                      Win_Place_Map : out Win_Place_Map_Pack.Map) ;


end Simulation_Storage;



--
Björn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-15 14:35 Ada.Containers warnings with gnat Björn Lundin
@ 2014-11-15 15:15 ` Björn Lundin
  2014-11-15 18:01 ` Jeffrey Carter
  1 sibling, 0 replies; 9+ messages in thread
From: Björn Lundin @ 2014-11-15 15:15 UTC (permalink / raw)


On 2014-11-15 15:35, Björn Lundin wrote:
> 
> Hi!
> I'm using a db to keep data in, that I retrieve and

Sorry, I forgot to mention

GNAT GPL 2014 64 bit on Debian Jessie


--
Björn


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-15 14:35 Ada.Containers warnings with gnat Björn Lundin
  2014-11-15 15:15 ` Björn Lundin
@ 2014-11-15 18:01 ` Jeffrey Carter
  2014-11-16 10:05   ` Björn Lundin
  1 sibling, 1 reply; 9+ messages in thread
From: Jeffrey Carter @ 2014-11-15 18:01 UTC (permalink / raw)


On 11/15/2014 07:35 AM, Björn Lundin wrote:
> 
> 
> The simulator was in a single file before -> no problem.
> So I then refactored and created a storage package and suddenly I get
> warnings like
> 
>  /home/bnl/bnlbot/botstart/bot-1-0/source/ada/local/utils/simulation_storage.ads
>     17.   package Sample_Map_Pack is new Ada.Containers.Ordered_Maps
>           |
>         >>> warning: in instantiation at a-coorma.ads:266
>         >>> warning: no entities of package "Ada.Streams" are referenced
> 
>     23.   package Marketid_Map_Pack is new Ada.Containers.Hashed_Maps
>           |
>         >>> warning: in instantiation at a-cohama.ads:342
>         >>> warning: no entities of package "Ada.Streams" are referenced
> 
>     30.   package Winner_Map_Pack is new Ada.Containers.Hashed_Maps
>           |
>         >>> warning: in instantiation at a-cohama.ads:342
>         >>> warning: no entities of package "Ada.Streams" are referenced
> 
>     37.   package Win_Place_Map_Pack is new Ada.Containers.Hashed_Maps
>           |
>         >>> warning: in instantiation at a-cohama.ads:342
>         >>> warning: no entities of package "Ada.Streams" are referenced

Did you change your compiler options? It appears that the compiler's
implementations of these standard pkgs with Ada.Streams but never reference it,
and that you're compiling with warnings of unreferenced things turned on.

-- 
Jeff Carter
"Gentlemen, you can't fight in here. This is the War Room!"
Dr. Strangelove
30


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-15 18:01 ` Jeffrey Carter
@ 2014-11-16 10:05   ` Björn Lundin
  2014-11-16 11:37     ` Björn Lundin
  0 siblings, 1 reply; 9+ messages in thread
From: Björn Lundin @ 2014-11-16 10:05 UTC (permalink / raw)


On 2014-11-15 19:01, Jeffrey Carter wrote:
> On 11/15/2014 07:35 AM, Björn Lundin wrote:
>>
>>
>> The simulator was in a single file before -> no problem.
>> So I then refactored and created a storage package and suddenly I get
>> warnings like
>>
>>  /home/bnl/bnlbot/botstart/bot-1-0/source/ada/local/utils/simulation_storage.ads
>>     17.   package Sample_Map_Pack is new Ada.Containers.Ordered_Maps
>>           |
>>         >>> warning: in instantiation at a-coorma.ads:266
>>         >>> warning: no entities of package "Ada.Streams" are referenced
>>
>>     23.   package Marketid_Map_Pack is new Ada.Containers.Hashed_Maps
>>           |
>>         >>> warning: in instantiation at a-cohama.ads:342
>>         >>> warning: no entities of package "Ada.Streams" are referenced
>>
>>     30.   package Winner_Map_Pack is new Ada.Containers.Hashed_Maps
>>           |
>>         >>> warning: in instantiation at a-cohama.ads:342
>>         >>> warning: no entities of package "Ada.Streams" are referenced
>>
>>     37.   package Win_Place_Map_Pack is new Ada.Containers.Hashed_Maps
>>           |
>>         >>> warning: in instantiation at a-cohama.ads:342
>>         >>> warning: no entities of package "Ada.Streams" are referenced
> 
> Did you change your compiler options? It appears that the compiler's
> implementations of these standard pkgs with Ada.Streams but never reference it,
> and that you're compiling with warnings of unreferenced things turned on.
> 


No, I did not. I just put the code into a package instead. That's it.
And I have never seen these kind of warnings on compiler/language
packages. It is like it recompiles them.

--
Björn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-16 10:05   ` Björn Lundin
@ 2014-11-16 11:37     ` Björn Lundin
  2014-11-16 17:32       ` Jeffrey Carter
  0 siblings, 1 reply; 9+ messages in thread
From: Björn Lundin @ 2014-11-16 11:37 UTC (permalink / raw)


On 2014-11-16 11:05, Björn Lundin wrote:

It seems to be ok until I - in the body - do

with Ada.Streams;
with Ada.Streams.Stream_IO;

With no code actually using stream_io I get



   21.   package Sample_Map_Pack is new Ada.Containers.Ordered_Maps
          |
        >>> warning: in instantiation at a-coorma.ads:266
        >>> warning: no entities of package "Ada.Streams" are referenced

    27.   package Marketid_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:154
        >>> warning: in instantiation at a-cohama.adb:85
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:165
        >>> warning: in instantiation at a-cohama.adb:85
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:165
        >>> warning: in instantiation at a-cohama.adb:103
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:154
        >>> warning: in instantiation at a-cohama.adb:104
        >>> warning: no entities of package "Ada.Streams" are referenced

    34.   package Winner_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:154
        >>> warning: in instantiation at a-cohama.adb:85
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:165
        >>> warning: in instantiation at a-cohama.adb:85
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:165
        >>> warning: in instantiation at a-cohama.adb:103
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:154
        >>> warning: in instantiation at a-cohama.adb:104
        >>> warning: no entities of package "Ada.Streams" are referenced

    41.   package Win_Place_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:154
        >>> warning: in instantiation at a-cohama.adb:85
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:165
        >>> warning: in instantiation at a-cohama.adb:85
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:165
        >>> warning: in instantiation at a-cohama.adb:103
        >>> warning: no entities of package "Ada.Streams" are referenced
        >>> warning: in instantiation at a-chtgop.ads:154
        >>> warning: in instantiation at a-cohama.adb:104
        >>> warning: no entities of package "Ada.Streams" are referenced

 763 lines: No errors, 50 warnings



If I then move on to actually use Streams_io, the warnings are reduced to


==============Error messages for source file:
/home/bnl/bnlbot/botstart/bot-1-0/source/ada/local/utils/simulation_storage.ads
    21.   package Sample_Map_Pack is new Ada.Containers.Ordered_Maps
          |
        >>> warning: in instantiation at a-coorma.ads:266
        >>> warning: no entities of package "Ada.Streams" are referenced

    27.   package Marketid_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced

    34.   package Winner_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced

    41.   package Win_Place_Map_Pack is new Ada.Containers.Hashed_Maps
          |
        >>> warning: in instantiation at a-cohama.ads:342
        >>> warning: no entities of package "Ada.Streams" are referenced

 763 lines: No errors, 8 warnings



the actual usage is just

    declare
     File   : Ada.Streams.Stream_IO.File_Type;
     Stream : Ada.Streams.Stream_IO.Stream_Access;
     Filename : String := Global_Map_Files(Marketid).Filename.Fix_String;
    begin
      Ada.Streams.Stream_IO.Open
          (File => File,
           Name => Filename,
           Mode => Ada.Streams.Stream_IO.In_File);
      Stream := Ada.Streams.Stream_IO.Stream (File);
      Marketid_Map_Pack.Map'Read(Stream, Marketid_Map);
      Ada.Streams.Stream_IO.Close(File);
      Log(Object & Service, "Marketid_Map read from file " & Filename);
    end;

for 3 different maps, and 3 corresponding Write sections


however I have put the generic instansiation between
pragma Warnings(Off)
pragma Warnings(On)

but it is still somewhat strange I think




--
Björn


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-16 11:37     ` Björn Lundin
@ 2014-11-16 17:32       ` Jeffrey Carter
  2014-11-17  8:13         ` Björn Lundin
  0 siblings, 1 reply; 9+ messages in thread
From: Jeffrey Carter @ 2014-11-16 17:32 UTC (permalink / raw)


On 11/16/2014 04:37 AM, Björn Lundin wrote:
> 
> It seems to be ok until I - in the body - do
> 
> with Ada.Streams;

Delete this one and see what happens. It shouldn't change anything since

> with Ada.Streams.Stream_IO;

includes it.

-- 
Jeff Carter
"What I wouldn't give for a large sock with horse manure in it."
Annie Hall
42

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-16 17:32       ` Jeffrey Carter
@ 2014-11-17  8:13         ` Björn Lundin
  2014-11-17 16:39           ` Anh Vo
  2014-11-17 17:27           ` Jeffrey Carter
  0 siblings, 2 replies; 9+ messages in thread
From: Björn Lundin @ 2014-11-17  8:13 UTC (permalink / raw)


On 2014-11-16 18:32, Jeffrey Carter wrote:
> On 11/16/2014 04:37 AM, Björn Lundin wrote:
>>
>> It seems to be ok until I - in the body - do
>>
>> with Ada.Streams;
> 
> Delete this one and see what happens. It shouldn't change anything since
> 
>> with Ada.Streams.Stream_IO;
> 
> includes it.
> 

Spot on. No warnings anymore.
Thanks.

But since the with-clause is in the body,
one would think that the warnings would refer to the body, not the spec...

I actually with'ed Ada.Streams for symmetry reason,

with Ada;
with Ada.Streams;
with Ada.Streams.Stream_IO;

looks better (to me) than just

with Ada.Streams.Stream_IO;


It seems that I will need some cognitive training to change my preferences.


--
Björn


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-17  8:13         ` Björn Lundin
@ 2014-11-17 16:39           ` Anh Vo
  2014-11-17 17:27           ` Jeffrey Carter
  1 sibling, 0 replies; 9+ messages in thread
From: Anh Vo @ 2014-11-17 16:39 UTC (permalink / raw)


On Monday, November 17, 2014 12:12:05 AM UTC-8, björn lundin wrote:
> On 2014-11-16 18:32, Jeffrey Carter wrote:
> > On 11/16/2014 04:37 AM, Björn Lundin wrote:
> >>
> >> It seems to be ok until I - in the body - do
> >>
> >> with Ada.Streams;
> > 
> > Delete this one and see what happens. It shouldn't change anything since
> > 
> >> with Ada.Streams.Stream_IO;
> > 
> > includes it.
> >  
> Spot on. No warnings anymore.
> Thanks.
> 
> But since the with-clause is in the body,
> one would think that the warnings would refer to the body, not the spec...
> 
> I actually with'ed Ada.Streams for symmetry reason,
> 
> with Ada;
> with Ada.Streams;
> with Ada.Streams.Stream_IO;
> 
> looks better (to me) than just
> 
> with Ada.Streams.Stream_IO;
>  
> It seems that I will need some cognitive training to change my preferences.
 
Yes, you should since it means more with less :-)

Anh Vo.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada.Containers warnings with gnat
  2014-11-17  8:13         ` Björn Lundin
  2014-11-17 16:39           ` Anh Vo
@ 2014-11-17 17:27           ` Jeffrey Carter
  1 sibling, 0 replies; 9+ messages in thread
From: Jeffrey Carter @ 2014-11-17 17:27 UTC (permalink / raw)


On 11/17/2014 01:13 AM, Björn Lundin wrote:
> 
> Spot on. No warnings anymore.
> Thanks.
> 
> But since the with-clause is in the body,
> one would think that the warnings would refer to the body, not the spec...

You shouldn't get the warnings in either case. I think you should report this.

-- 
Jeff Carter
"So if I understand 'The Matrix Reloaded' correctly, the Matrix is
basically a Microsoft operating system--it runs for a while and
then crashes and reboots. By design, no less. Neo is just a
memory leak that's too hard to fix, so they left him in ... The
users don't complain because they're packed in slush and kept
sedated."
Marin D. Condic
65

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-11-17 17:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15 14:35 Ada.Containers warnings with gnat Björn Lundin
2014-11-15 15:15 ` Björn Lundin
2014-11-15 18:01 ` Jeffrey Carter
2014-11-16 10:05   ` Björn Lundin
2014-11-16 11:37     ` Björn Lundin
2014-11-16 17:32       ` Jeffrey Carter
2014-11-17  8:13         ` Björn Lundin
2014-11-17 16:39           ` Anh Vo
2014-11-17 17:27           ` Jeffrey Carter

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