comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  2023-06-26 18:56  0%     ` Jere
  2023-06-26 19:35  0%       ` Kenneth Wolcott
@ 2023-06-26 19:48  0%       ` Simon Wright
  1 sibling, 0 replies; 130+ results
From: Simon Wright @ 2023-06-26 19:48 UTC (permalink / raw)


Jere <jhb.chat@gmail.com> writes:

> On Sunday, June 25, 2023 at 5:49:11 PM UTC-4, Keith Thompson wrote:
>> Simon Wright writes: 
>> [...]
>> > But you say you know that. I wonder whether it's the crunched filenames 
>> > that are confusing? (a legacy of the days when DOS 8.3 filenames were 
>> > required for a large part of GNAT's target audience). You can find the 
>> > crunched filename for a package using gnatkr (gnat krunch): 
>> >
>> > $ gnatkr ada.sequential_io.ads 
>> [fixed typo]
>> > a-sequio.ads 
>> > 
>> > (you don't actually need whatever's after the final period to be the 
>> > actual file extension: you could use '.open' or just '.').
>> Which raises a question: Why does GNAT still use crunched filenames? It 
>> probably makes sense to continue to support them (does anyone use GNAT 
>> on MS-DOS?), but I wouldn't think it would be difficult to use full file 
>> names on the vast majority of systems that support them. It's not a 
>> huge deal, but using full file names where possible would be less 
>> annoying. 
>
> Unless they changed how the GNAT compiler works in the last few years,
> then my guess is inertia
> to do that.  Right before the pandemic hit, I had the neat idea of
> doing my own bare metal
> runtime and to use normal uncrunched names.  The RTS compiled just
> fine doing that.  However,
> when I tried to use the RTS to build a full fledged program, it failed
> to find the package in the RTS.
> I don't recall if it failed at compile time or link time, but
> crunching the names and recompiling the
> RTS fixed the issue.  So something in their compiler requires the
> crunched names, or if they have
> since changed that, used to require it.

The package in the compiler that deals with crunched names is Rtsfind,
https://github.com/gcc-mirror/gcc/blob/master/gcc/ada/rtsfind.ads

^ permalink raw reply	[relevance 0%]

* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  2023-06-26 18:56  0%     ` Jere
@ 2023-06-26 19:35  0%       ` Kenneth Wolcott
  2023-06-26 19:48  0%       ` Simon Wright
  1 sibling, 0 replies; 130+ results
From: Kenneth Wolcott @ 2023-06-26 19:35 UTC (permalink / raw)


> Simon Wright writes: 
> $ gnatkr ada.sequential_io.ads 
> a-sequio.ads 

Simon, Keith, Jere:

Yes, the crunched names are annoying.  Too bad that they seem to be required even now...

I'm now writing a Perl script (later to be converted to Ada) which does the "unkrunch" :-)

Seems like a missing utility for humans to use Ada :-)

Thanks,
Ken

^ permalink raw reply	[relevance 0%]

* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  2023-06-25 21:49  0%   ` Keith Thompson
@ 2023-06-26 18:56  0%     ` Jere
  2023-06-26 19:35  0%       ` Kenneth Wolcott
  2023-06-26 19:48  0%       ` Simon Wright
  0 siblings, 2 replies; 130+ results
From: Jere @ 2023-06-26 18:56 UTC (permalink / raw)


On Sunday, June 25, 2023 at 5:49:11 PM UTC-4, Keith Thompson wrote:
> Simon Wright writes: 
> [...]
> > But you say you know that. I wonder whether it's the crunched filenames 
> > that are confusing? (a legacy of the days when DOS 8.3 filenames were 
> > required for a large part of GNAT's target audience). You can find the 
> > crunched filename for a package using gnatkr (gnat krunch): 
> >
> > $ gnatkr ada.sequential_io.ads 
> [fixed typo]
> > a-sequio.ads 
> > 
> > (you don't actually need whatever's after the final period to be the 
> > actual file extension: you could use '.open' or just '.').
> Which raises a question: Why does GNAT still use crunched filenames? It 
> probably makes sense to continue to support them (does anyone use GNAT 
> on MS-DOS?), but I wouldn't think it would be difficult to use full file 
> names on the vast majority of systems that support them. It's not a 
> huge deal, but using full file names where possible would be less 
> annoying. 

Unless they changed how the GNAT compiler works in the last few years, then my guess is inertia
to do that.   Right before the pandemic hit, I had the neat idea of doing my own bare metal 
runtime and to use normal uncrunched names.  The RTS compiled just fine doing that.  However,
when I tried to use the RTS to build a full fledged program, it failed to find the package in the RTS.
I don't recall if it failed at compile time or link time, but crunching the names and recompiling the
RTS fixed the issue.  So something in their compiler requires the crunched names, or if they have
since changed that, used to require it.

^ permalink raw reply	[relevance 0%]

* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  2023-06-25 10:15  4% ` Simon Wright
  2023-06-25 15:28  0%   ` Simon Wright
  2023-06-25 17:00  0%   ` Kenneth Wolcott
@ 2023-06-25 21:49  0%   ` Keith Thompson
  2023-06-26 18:56  0%     ` Jere
  2 siblings, 1 reply; 130+ results
From: Keith Thompson @ 2023-06-25 21:49 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:
[...]
> But you say you know that. I wonder whether it's the crunched filenames
> that are confusing? (a legacy of the days when DOS 8.3 filenames were
> required for a large part of GNAT's target audience). You can find the
> crunched filename for a package using gnatkr (gnat krunch):
>
>    $ gnatkr ada.sequential_io.ads
[fixed typo]
>    a-sequio.ads
>
> (you don't actually need whatever's after the final period to be the
> actual file extension: you could use '.open' or just '.').

Which raises a question: Why does GNAT still use crunched filenames?  It
probably makes sense to continue to support them (does anyone use GNAT
on MS-DOS?), but I wouldn't think it would be difficult to use full file
names on the vast majority of systems that support them.  It's not a
huge deal, but using full file names where possible would be less
annoying.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

^ permalink raw reply	[relevance 0%]

* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  2023-06-25 10:15  4% ` Simon Wright
  2023-06-25 15:28  0%   ` Simon Wright
@ 2023-06-25 17:00  0%   ` Kenneth Wolcott
  2023-06-25 21:49  0%   ` Keith Thompson
  2 siblings, 0 replies; 130+ results
From: Kenneth Wolcott @ 2023-06-25 17:00 UTC (permalink / raw)


Thank you Simon!

On Sunday, June 25, 2023 at 3:15:54 AM UTC-7, Simon Wright wrote:
> Kenneth Wolcott writes: 
> 
> > I have gnat 13.1.0 on my M1 Mac; 
> > 
> > (thank you, Simon! <GRIN>)
> :bow:
> > I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
> If you just want to insect them, see below: if you want to alter them, 
> that'd be a bit tricker. As far as I can remember, GNAT Pro releases 
> provide for rebuilding the runtime, but the FSF builds don't.
> > I can find the Ada libraries (*.ad[sb]) but it sometimes is hard to 
> > (reliably) find all of the GNAT Ada libraries in external 
> > documentation.
> They're in {prefix}/lib/gcc/{target}/{release}/adainclude/ - i.e., in 
> your case (unless you've moved the install) 
> 
> /opt/gcc-13.1.0-aarch64/lib/gcc/aarch64-apple-darwin21/13.1.0/adainclude/ 

This is all the information that I needed, thank you!

> But you say you know that. I wonder whether it's the crunched filenames 
> that are confusing? (a legacy of the days when DOS 8.3 filenames were 
> required for a large part of GNAT's target audience). You can find the 
> crunched filename for a package using gnatkr (gnat krunch): 
> 
> $ gnatkr gnatkr ada.sequential_io.ads 
> a-sequio.ads 

This is nice, thank you!

> (you don't actually need whatever's after the final period to be the 
> actual file extension: you could use '.open' or just '.').

Ken Wolcott

^ permalink raw reply	[relevance 0%]

* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  2023-06-25 10:15  4% ` Simon Wright
@ 2023-06-25 15:28  0%   ` Simon Wright
  2023-06-25 17:00  0%   ` Kenneth Wolcott
  2023-06-25 21:49  0%   ` Keith Thompson
  2 siblings, 0 replies; 130+ results
From: Simon Wright @ 2023-06-25 15:28 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

>    $ gnatkr gnatkr ada.sequential_io.ads
>    a-sequio.ads

Only one 'gnatkr', ofc!

^ permalink raw reply	[relevance 0%]

* Re: I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?
  @ 2023-06-25 10:15  4% ` Simon Wright
  2023-06-25 15:28  0%   ` Simon Wright
                     ` (2 more replies)
  0 siblings, 3 replies; 130+ results
From: Simon Wright @ 2023-06-25 10:15 UTC (permalink / raw)


Kenneth Wolcott <kennethwolcott@gmail.com> writes:

> I have gnat 13.1.0 on my M1 Mac;
>
> (thank you, Simon! <GRIN>)

:bow:

> I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they?

If you just want to insect them, see below: if you want to alter them,
that'd be a bit tricker. As far as I can remember, GNAT Pro releases
provide for rebuilding the runtime, but the FSF builds don't.

> I can find the Ada libraries (*.ad[sb]) but it sometimes is hard to
> (reliably) find all of the GNAT Ada libraries in external
> documentation.

They're in {prefix}/lib/gcc/{target}/{release}/adainclude/ - i.e., in
your case (unless you've moved the install)

   /opt/gcc-13.1.0-aarch64/lib/gcc/aarch64-apple-darwin21/13.1.0/adainclude/

But you say you know that. I wonder whether it's the crunched filenames
that are confusing? (a legacy of the days when DOS 8.3 filenames were
required for a large part of GNAT's target audience). You can find the
crunched filename for a package using gnatkr (gnat krunch):

   $ gnatkr gnatkr ada.sequential_io.ads
   a-sequio.ads

(you don't actually need whatever's after the final period to be the
actual file extension: you could use '.open' or just '.').

^ permalink raw reply	[relevance 4%]

* Re: String view of file
    2022-11-21 13:48  6% ` Jeffrey R.Carter
@ 2022-11-21 16:11  5% ` Marius Amado-Alves
  1 sibling, 0 replies; 130+ results
From: Marius Amado-Alves @ 2022-11-21 16:11 UTC (permalink / raw)


Use Ada.Sequential_IO (Character), load to an Unbounded_String, save from a String or Unbounded_String.

^ permalink raw reply	[relevance 5%]

* Re: String view of file
  2022-11-21 13:48  6% ` Jeffrey R.Carter
@ 2022-11-21 15:52  0%   ` Niklas Holsti
  0 siblings, 0 replies; 130+ results
From: Niklas Holsti @ 2022-11-21 15:52 UTC (permalink / raw)


On 2022-11-21 15:48, Jeffrey R.Carter wrote:
> On 2022-11-21 09:30, Jesper Quorning wrote:
>>
>> Is it possible to write something like this with ADA
> 
> "Ada" is a woman's name, not an acronymn.
> 
>> package my_rw_file is new file
>>    (name => "whatever"
>>     ,mode => read_write
>>     ,implementation => standard -- or portable or fast
>>    );
>> package as_string is new. xxx(from => my_rw_file);
>>
>> -- parse (as_string);
>> package data is new parse (as_string, format => markdown); -- or whatever
> 
> If I presume that the '.' in the declaration of As_String is a typo, 
> what you have here is a sequence of related generic pkg instantiations, 
> so you can write this in Ada if you have the corresponding generic pkgs. 
> I have no idea what the result would provide.
> 
> If you want to read the arbitrary contents of a file into a String, 
> that's easily done:
> 
> with Ada.Directories;
> 
> package String_A_File is
>     use type Ada.Directories.File_Size;
> 
>     function File_As_String (Name : in String) return String with
>        Pre  => Ada.Directories.Exists (Name) and then
>                Ada.Directories.Size (Name) <=
>                Ada.Directories.File_Size (Integer'Last),
>        Post => File_As_String'Result'First = 1 and
>                File_As_String'Result'Last =
>                Integer (Ada.Directories.Size (Name) );
> end String_A_File;
> 
> with Ada.Sequential_IO;
> 
> package body String_A_File is
>     function File_As_String (Name : in String) return String is
>        subtype FAS is String (1 .. Integer (Ada.Directories.Size (Name) 
> ) );
> 
>        package FAS_IO is new Ada.Sequential_IO (Element_Type => FAS);
> 
>        File   : FAS_IO.File_Type;
>        Result : FAS;
>     begin -- File_As_String
>        FAS_IO.Open (File => File, Mode => FAS_IO.In_File, Name => Name);
>        FAS_IO.Read (File => File, Item => Result;
>        FAS_IO.Close (File => File);
> 
>        return Result;
>     end File_As_String;
> end String_A_File;
> 
> This presumes that Result will fit on the stack. If that's likely to be 
> a problem, then you will need to use Unbounded_String and read the file 
> Character by Character.


For the OP's benefit (Jeffrey of course knows this): an alternative to 
Unbounded_String is to allocate the Result string on the heap, and 
return an access to the heap string. With that method, you can still 
read the entire string with one call of FAS_IO.Read instead of Character 
by Character.

^ permalink raw reply	[relevance 0%]

* Re: String view of file
  @ 2022-11-21 13:48  6% ` Jeffrey R.Carter
  2022-11-21 15:52  0%   ` Niklas Holsti
  2022-11-21 16:11  5% ` Marius Amado-Alves
  1 sibling, 1 reply; 130+ results
From: Jeffrey R.Carter @ 2022-11-21 13:48 UTC (permalink / raw)


On 2022-11-21 09:30, Jesper Quorning wrote:
> 
> Is it possible to write something like this with ADA

"Ada" is a woman's name, not an acronymn.

> package my_rw_file is new file
>    (name => "whatever"
>     ,mode => read_write
>     ,implementation => standard -- or portable or fast
>    );
> package as_string is new. xxx(from => my_rw_file);
> 
> -- parse (as_string);
> package data is new parse (as_string, format => markdown); -- or whatever

If I presume that the '.' in the declaration of As_String is a typo, what you 
have here is a sequence of related generic pkg instantiations, so you can write 
this in Ada if you have the corresponding generic pkgs. I have no idea what the 
result would provide.

If you want to read the arbitrary contents of a file into a String, that's 
easily done:

with Ada.Directories;

package String_A_File is
    use type Ada.Directories.File_Size;

    function File_As_String (Name : in String) return String with
       Pre  => Ada.Directories.Exists (Name) and then
               Ada.Directories.Size (Name) <=
               Ada.Directories.File_Size (Integer'Last),
       Post => File_As_String'Result'First = 1 and
               File_As_String'Result'Last =
               Integer (Ada.Directories.Size (Name) );
end String_A_File;

with Ada.Sequential_IO;

package body String_A_File is
    function File_As_String (Name : in String) return String is
       subtype FAS is String (1 .. Integer (Ada.Directories.Size (Name) ) );

       package FAS_IO is new Ada.Sequential_IO (Element_Type => FAS);

       File   : FAS_IO.File_Type;
       Result : FAS;
    begin -- File_As_String
       FAS_IO.Open (File => File, Mode => FAS_IO.In_File, Name => Name);
       FAS_IO.Read (File => File, Item => Result;
       FAS_IO.Close (File => File);

       return Result;
    end File_As_String;
end String_A_File;

This presumes that Result will fit on the stack. If that's likely to be a 
problem, then you will need to use Unbounded_String and read the file Character 
by Character.

-- 
Jeff Carter
"I have a very small head and I had
better learn to live with it ..."
Edsger Dijkstra
158

^ permalink raw reply	[relevance 6%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 20:54 14%       ` Niklas Holsti
@ 2021-03-23  9:18  7%         ` Jeffrey R. Carter
  0 siblings, 0 replies; 130+ results
From: Jeffrey R. Carter @ 2021-03-23  9:18 UTC (permalink / raw)


On 3/22/21 9:54 PM, Niklas Holsti wrote:
> 
> Not quite. From the RM:
> 
>     generic
>        type Element_Type is private;
>     package Ada.Direct_IO is
>     ...
> 
> and
> 
>     generic
>        type Element_Type(<>) is private;
>     package Ada.Sequential_IO is

Ah, yes. Having started with Ada 83, I sometimes forget about changes like this.

-- 
Jeff Carter
"[I]f you ask, 'Why does Ada do/have this?',
the answer often makes you a better programmer."
Chad R. Meiners
177

^ permalink raw reply	[relevance 7%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 19:41  6%     ` Jeffrey R. Carter
  2021-03-22 20:54 14%       ` Niklas Holsti
@ 2021-03-22 21:25  6%       ` Shark8
  1 sibling, 0 replies; 130+ results
From: Shark8 @ 2021-03-22 21:25 UTC (permalink / raw)


On Monday, March 22, 2021 at 1:41:59 PM UTC-6, Jeffrey R. Carter wrote:
> On 3/22/21 7:14 PM, John Perry wrote: 
> > 
> > For Direct_IO I inferred this fact from ARM A.8.3, "the file is viewed as a set of elements occupying consecutive positions in linear order", but I don't see a similar indication for Sequential_IO. Is there a warning in the ARM about this? 
> > 
> > (I do see the warning in Barnes' book, which I had consulted! and saw! and decided not to use Direct_IO as a result! but somehow read the same thing about Sequential_IO & either forgot or mis-concluded something. So I acknowledge my stupidity here.)
> The only differences between Direct_IO and Sequential_IO are that Direct_IO 
> allows random access and mixed input and output. In both cases the file contains 
> a sequence of binary representations of values of a single type. 
> 
> I don't really understand why Sequential_IO exists, since Direct_IO provides a 
> superset of Sequential_IO's functionality.
Going by some of the stuff where I work, most of which has foundational-stuff from the 80s and 90s (though not in Ada), the "Direct IO" is considered to be raw read/write concerning hardware or UDP datagram-packets or such. So, I would assume that by the nomenculture [and usage] of the day Direct_IO was meant for similar. Sequential_IO though sounds like a "and here we have a file full of entries of Type X, which we made generic to save ourselves the headache of maintaining multiple identical-except-for-type package."

^ permalink raw reply	[relevance 6%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 19:41  6%     ` Jeffrey R. Carter
@ 2021-03-22 20:54 14%       ` Niklas Holsti
  2021-03-23  9:18  7%         ` Jeffrey R. Carter
  2021-03-22 21:25  6%       ` Shark8
  1 sibling, 1 reply; 130+ results
From: Niklas Holsti @ 2021-03-22 20:54 UTC (permalink / raw)


On 2021-03-22 21:41, Jeffrey R. Carter wrote:

> The only differences between Direct_IO and Sequential_IO are that 
> Direct_IO allows random access and mixed input and output. In both cases 
> the file contains a sequence of binary representations of values of a 
> single type.
> 
> I don't really understand why Sequential_IO exists, since Direct_IO 
> provides a superset of Sequential_IO's functionality.

Not quite. From the RM:

    generic
       type Element_Type is private;
    package Ada.Direct_IO is
    ...

and

    generic
       type Element_Type(<>) is private;
    package Ada.Sequential_IO is
    ...

So Sequential_IO allows unknown discriminants in the element type, in 
other words elements that can vary in size, which obviously hampers 
random (indexed) access to elements in the file, which Direct_IO allows.

There is also this note for Direct_IO:

RM A.8.4(19.a): Reason: The Element_Type formal of Direct_IO does not 
have an unknown_discriminant_part (unlike Sequential_IO) so that the 
implementation can make use of the ability to declare uninitialized 
variables of the type.

^ permalink raw reply	[relevance 14%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 18:14  6%   ` John Perry
@ 2021-03-22 19:41  6%     ` Jeffrey R. Carter
  2021-03-22 20:54 14%       ` Niklas Holsti
  2021-03-22 21:25  6%       ` Shark8
  0 siblings, 2 replies; 130+ results
From: Jeffrey R. Carter @ 2021-03-22 19:41 UTC (permalink / raw)


On 3/22/21 7:14 PM, John Perry wrote:
> 
> For Direct_IO I inferred this fact from ARM A.8.3, "the file is viewed as a set of elements occupying consecutive positions in linear order", but I don't see a similar indication for Sequential_IO. Is there a warning in the ARM about this?
> 
> (I do see the warning in Barnes' book, which I had consulted! and saw! and decided not to use Direct_IO as a result! but somehow read the same thing about Sequential_IO & either forgot or mis-concluded something. So I acknowledge my stupidity here.)

The only differences between Direct_IO and Sequential_IO are that Direct_IO 
allows random access and mixed input and output. In both cases the file contains 
a sequence of binary representations of values of a single type.

I don't really understand why Sequential_IO exists, since Direct_IO provides a 
superset of Sequential_IO's functionality.

-- 
Jeff Carter
"One day he told me he was a gynecologist. He
couldn't speak no foreign languages."
Take the Money and Run
147

^ permalink raw reply	[relevance 6%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 17:40  6% ` Jeffrey R. Carter
@ 2021-03-22 18:14  6%   ` John Perry
  2021-03-22 19:41  6%     ` Jeffrey R. Carter
  0 siblings, 1 reply; 130+ results
From: John Perry @ 2021-03-22 18:14 UTC (permalink / raw)


Jeff & Dmitry

On Monday, March 22, 2021 at 12:40:39 PM UTC-5, Jeffrey R. Carter wrote:
> On 3/22/21 6:13 PM, John Perry wrote: 
> > The following worked as expected (sorry for the abbreviations but I think it will be clear): 
> > 
> >>> P1.Create; P1.Write; P1.Close; P2.Open(Append_File); P2.Write; P2.Close;
> This is asking for trouble,
> > 
> > However, this: 
> > 
> >>> P3.Open(Append_File); P3.Write; P3.Close; 
> > 
> > ...wrote a few bytes of junk between T2's data and T3's data.
> which you got. 

Thank you, I got a laugh out of that :-)

> When you open a P3.File_Type with mode Append_File, it expects the file to 
> contain an integral number of values of T3 already. What happens if it doesn't 
> appears to be undefined. 

For Direct_IO I inferred this fact from ARM A.8.3, "the file is viewed as a set of elements occupying consecutive positions in linear order", but I don't see a similar indication for Sequential_IO. Is there a warning in the ARM about this?

(I do see the warning in Barnes' book, which I had consulted! and saw! and decided not to use Direct_IO as a result! but somehow read the same thing about Sequential_IO & either forgot or mis-concluded something. So I acknowledge my stupidity here.)

> Either create a record with components of the the three types, instantiate 
> Sequential_IO for that, and write all three values at once, or use streams for 
> heterogeneous I/O. 

I'll look into Streams, thanks.

john perry

^ permalink raw reply	[relevance 6%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 17:13  5% surprise data from Ada.Sequential_IO John Perry
  2021-03-22 17:40  6% ` Jeffrey R. Carter
@ 2021-03-22 17:48  6% ` Dmitry A. Kazakov
  1 sibling, 0 replies; 130+ results
From: Dmitry A. Kazakov @ 2021-03-22 17:48 UTC (permalink / raw)


On 2021-03-22 18:13, John Perry wrote:

> I was using gnat 2020 CE on a Linux machine the other day, and wanted to write out data for three different types T1, T2, T3 to a file. I instantiated a Sequential_IO package for each; call them P1, P2, P3.
> 
> The following worked as expected (sorry for the abbreviations but I think it will be clear):
> 
>>> P1.Create; P1.Write; P1.Close; P2.Open(Append_File); P2.Write; P2.Close;
> 
> However, this:
> 
>>> P3.Open(Append_File); P3.Write; P3.Close;
> 
> ...wrote a few bytes of junk between T2's data and T3's data.
> 
> I used a hex editor to check the output file between writes, and there was no junk after P2.Close nor after P3.Open; it always came at the beginning of P3.Write.
> 
> I reworked the type definitions so that T3's data was included at the end of T2, and in this case P2.Write wrote the data properly, as desired. However, this is not the sort of permanent solution I'd want.
> 
> Has anyone else encountered this? Could this be due to alignment issues? Is there some way to avoid this without putting the data there?

I did not use Sequential_IO for decades. I doubt it was ever intended 
for the misuse you invented.

For practical point of view, I would consider this package obsolete, 
superseded by Ada.Streams.Stream_IO. It is exactly meant for your case, 
especially if you override the attributes of T1, T2, T3 (to make it 
portable).

And you are in full control of what is going on, e.g. no stuff like 
vertical formats and stupid EOF sequences.

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

^ permalink raw reply	[relevance 6%]

* Re: surprise data from Ada.Sequential_IO
  2021-03-22 17:13  5% surprise data from Ada.Sequential_IO John Perry
@ 2021-03-22 17:40  6% ` Jeffrey R. Carter
  2021-03-22 18:14  6%   ` John Perry
  2021-03-22 17:48  6% ` Dmitry A. Kazakov
  1 sibling, 1 reply; 130+ results
From: Jeffrey R. Carter @ 2021-03-22 17:40 UTC (permalink / raw)


On 3/22/21 6:13 PM, John Perry wrote:
> Hello all
> 
> I was using gnat 2020 CE on a Linux machine the other day, and wanted to write out data for three different types T1, T2, T3 to a file. I instantiated a Sequential_IO package for each; call them P1, P2, P3.
> 
> The following worked as expected (sorry for the abbreviations but I think it will be clear):
> 
>>> P1.Create; P1.Write; P1.Close; P2.Open(Append_File); P2.Write; P2.Close;

This is asking for trouble,

> 
> However, this:
> 
>>> P3.Open(Append_File); P3.Write; P3.Close;
> 
> ...wrote a few bytes of junk between T2's data and T3's data.

which you got.

When you open a P3.File_Type with mode Append_File, it expects the file to 
contain an integral number of values of T3 already. What happens if it doesn't 
appears to be undefined.

Either create a record with components of the the three types, instantiate 
Sequential_IO for that, and write all three values at once, or use streams for 
heterogeneous I/O.

-- 
Jeff Carter
"One day he told me he was a gynecologist. He
couldn't speak no foreign languages."
Take the Money and Run
147

^ permalink raw reply	[relevance 6%]

* surprise data from Ada.Sequential_IO
@ 2021-03-22 17:13  5% John Perry
  2021-03-22 17:40  6% ` Jeffrey R. Carter
  2021-03-22 17:48  6% ` Dmitry A. Kazakov
  0 siblings, 2 replies; 130+ results
From: John Perry @ 2021-03-22 17:13 UTC (permalink / raw)


Hello all

I was using gnat 2020 CE on a Linux machine the other day, and wanted to write out data for three different types T1, T2, T3 to a file. I instantiated a Sequential_IO package for each; call them P1, P2, P3.

The following worked as expected (sorry for the abbreviations but I think it will be clear):

>> P1.Create; P1.Write; P1.Close; P2.Open(Append_File); P2.Write; P2.Close;

However, this:

>> P3.Open(Append_File); P3.Write; P3.Close;

...wrote a few bytes of junk between T2's data and T3's data.

I used a hex editor to check the output file between writes, and there was no junk after P2.Close nor after P3.Open; it always came at the beginning of P3.Write.

I reworked the type definitions so that T3's data was included at the end of T2, and in this case P2.Write wrote the data properly, as desired. However, this is not the sort of permanent solution I'd want.

Has anyone else encountered this? Could this be due to alignment issues? Is there some way to avoid this without putting the data there?

thanks in advance
john perry

^ permalink raw reply	[relevance 5%]

* Re: Read/write access to Unix character devices
  2020-12-21  4:59  4% Read/write access to Unix character devices philip...@gmail.com
  2020-12-22  1:23  5% ` Randy Brukardt
@ 2020-12-28 13:26  0% ` Björn Lundin
  1 sibling, 0 replies; 130+ results
From: Björn Lundin @ 2020-12-28 13:26 UTC (permalink / raw)


Den 2020-12-21 kl. 05:59, skrev philip...@gmail.com:
> Lately I have been working with Unix (really Linux, FreeBSD, and OpenBSD) character devices (these happen to be USB raw HID devices, but the problem is more general than that).  The way these work is that each hardware device has a character device node file in /dev/, like /dev/hidraw1.  You open the file for both read and write access.  Then you can send a command to the device by writing a binary blob and get a response by subsequently reading a binary blob.  For what I am doing, it is important not to block on reads forever if there is not response forthcoming, so I need at least read timeouts.
> 
> So far, I have been binding the C library functions open(), close(), read(), write(), and poll() with pragma Import.  That works, but I have wondered if there is some way of accomplishing the same thing more portably.  The packages GNAT.Sockets and GNAT.Serial_Communicatons can be viewed as special case solutions, but I would like a general solution.
> 
> What I would really like is Ada.Sequential_IO with InOut_File and a timeout mechanism, perhaps like the select() wrapper in GNAT.Sockets.
> 
> So far I haven't found anything in the Ada. or GNAT. that supports InOut_File semantics (other than Direct_IO) let alone timeouts.  Does anybody have any suggestions?
> 
> Phil
> 


I'm perhaps too late for a useful suggestion, but I use this pattern 
when I pass messages through named pipes between unrelated processes.


The reading process starts a task T1 which reads the pipe blocking.
When data arrives it puts it in a list via a protected object,
then it goes back to read blocking again.


T1:
loop
   read device
   PO.Put(data from device)
   exit when data is special shutdown-message
end loop


The main of the process does a IO.receive which in turn does a 'Get' on 
a protected object where 'get' is an entry of the PO with condition 
list.count > 0

main:
   loop
     IO.Receive(Data, Timeout)
     case Data.id is
       when timeout => DoSomethingElse
       when  reply  => Treat(Data)
       when shutdown => exit
     end case
   end loop;


So - the main hangs on receive until a message arrives.
And with receive, there is an optional timeout, that if > 0, starts a 
new task T2 that is a timer. If no message has arrived within time,
a timeout message is put by T2 into the list, and the T2 dies.

pkg IO
procedure Receive (msg out: some type ; timeout : duration := 0.0) is
   TTP : Timer_Task_Pointer_Type;
   TO  : aliased Duration := Timeout;
begin
  if Timeout > 0.0 then
    TTP := new Timer_Task_Type(TO'Unchecked_access);
    PO.Get(msg); <-- we hang here until msg from device or timeout from T2
    begin
      TTP.Stop;
      loop
        exit when TTP.all'Terminated;
        delay 0.0001; --workaround gnat bug
      end loop;
    exception
      when Tasking_Error => null;
    end;
    Free(TTP);
  end if;
end receive;


T2
   task type Timer_Task_Type(Timeout_Time : access Duration) is
     entry Stop;
   end Timer_Task_Type;

   task body Timer_Task_Type is
     Timeout_Message : Message_Type;
   begin
     select
       delay Timeout_Time.all;
       Timeout_Message.Msg.Header.Identity := Time_Out_Identity;
       PO.Put(Timeout_Message);
     or
       accept Stop;
     end select;
   end Timer_Task_Type;

   type Timer_Task_Pointer_Type is access all Timer_Task_Type;

   procedure Free is new 
Unchecked_Deallocation(Timer_Task_Type,Timer_Task_Pointer_Type);




Main is released by this timeout message and can do other things while 
T1 still hangs on the device waiting for data.


To exit the process I post a special exit message that the task puts 
into the list and then exits its task loop, thus dies.

Then the process shuts down when it acts upon the shutdown message.

In your case you may not be able to send such a message to the task, but
that does perhaps not matter. abort the task when shutting down your 
process - if you ever shut it down that is.


-- 
Björn

^ permalink raw reply	[relevance 0%]

* Re: Read/write access to Unix character devices
  2020-12-21  4:59  4% Read/write access to Unix character devices philip...@gmail.com
@ 2020-12-22  1:23  5% ` Randy Brukardt
  2020-12-28 13:26  0% ` Björn Lundin
  1 sibling, 0 replies; 130+ results
From: Randy Brukardt @ 2020-12-22  1:23 UTC (permalink / raw)


I would use Stream_IO for this, but you'd need help from your implementer to 
get timeouts/nonblocking I/O. If they have them, they'd be some sort of Form 
parameter (that's what the typically ignored Form parameter is for).

Stream_IO is a lot more flexible that Sequential_IO and Direct_IO. (Some 
implementations implement those older Ada 83 packages in terms of 
Stream_IO.)

                          Randy.

"philip...@gmail.com" <philip.munts@gmail.com> wrote in message 
news:6ece98b8-a82e-40e7-9a0e-37b40a175fb0n@googlegroups.com...
Lately I have been working with Unix (really Linux, FreeBSD, and OpenBSD) 
character devices (these happen to be USB raw HID devices, but the problem 
is more general than that).  The way these work is that each hardware device 
has a character device node file in /dev/, like /dev/hidraw1.  You open the 
file for both read and write access.  Then you can send a command to the 
device by writing a binary blob and get a response by subsequently reading a 
binary blob.  For what I am doing, it is important not to block on reads 
forever if there is not response forthcoming, so I need at least read 
timeouts.

So far, I have been binding the C library functions open(), close(), read(), 
write(), and poll() with pragma Import.  That works, but I have wondered if 
there is some way of accomplishing the same thing more portably.  The 
packages GNAT.Sockets and GNAT.Serial_Communicatons can be viewed as special 
case solutions, but I would like a general solution.

What I would really like is Ada.Sequential_IO with InOut_File and a timeout 
mechanism, perhaps like the select() wrapper in GNAT.Sockets.

So far I haven't found anything in the Ada. or GNAT. that supports 
InOut_File semantics (other than Direct_IO) let alone timeouts.  Does 
anybody have any suggestions?

Phil 


^ permalink raw reply	[relevance 5%]

* Read/write access to Unix character devices
@ 2020-12-21  4:59  4% philip...@gmail.com
  2020-12-22  1:23  5% ` Randy Brukardt
  2020-12-28 13:26  0% ` Björn Lundin
  0 siblings, 2 replies; 130+ results
From: philip...@gmail.com @ 2020-12-21  4:59 UTC (permalink / raw)


Lately I have been working with Unix (really Linux, FreeBSD, and OpenBSD) character devices (these happen to be USB raw HID devices, but the problem is more general than that).  The way these work is that each hardware device has a character device node file in /dev/, like /dev/hidraw1.  You open the file for both read and write access.  Then you can send a command to the device by writing a binary blob and get a response by subsequently reading a binary blob.  For what I am doing, it is important not to block on reads forever if there is not response forthcoming, so I need at least read timeouts.

So far, I have been binding the C library functions open(), close(), read(), write(), and poll() with pragma Import.  That works, but I have wondered if there is some way of accomplishing the same thing more portably.  The packages GNAT.Sockets and GNAT.Serial_Communicatons can be viewed as special case solutions, but I would like a general solution.

What I would really like is Ada.Sequential_IO with InOut_File and a timeout mechanism, perhaps like the select() wrapper in GNAT.Sockets.

So far I haven't found anything in the Ada. or GNAT. that supports InOut_File semantics (other than Direct_IO) let alone timeouts.  Does anybody have any suggestions?

Phil

^ permalink raw reply	[relevance 4%]

* Re: A little trouble with very large arrays.
  @ 2018-10-05  6:17  5% ` Jacob Sparre Andersen
  0 siblings, 0 replies; 130+ results
From: Jacob Sparre Andersen @ 2018-10-05  6:17 UTC (permalink / raw)


Shark8 <onewingedshark@gmail.com> writes:

> The main-problem right now is the "Primary Data Array" which can have
> a dimensionality in 1..999, each itself with some non-zero range. (In
> the files these are specified by keywords in the file like NAXIS = n,
> NAXIS1 = n_1, NAXIS2 = n_2, and so on until the NAXISn = n_n
> keyword/value pair is encountered.)

Ouch. :-(

Something like this will work, but it doesn't look nice:

package Variable_Dimensionality is

   type Raw is array (Positive range <>,
                      Positive range <>,
                      Positive range <>) of Boolean;

   type Nice (Dim_1, Dim_2, Dim_3 : Positive) is
      record
         Data : Raw (1 .. Dim_1,
                     1 .. Dim_2,
                     1 .. Dim_3);
      end record;

end Variable_Dimensionality;

> (As another interesting constraint, the file-format mandates a sort of
> block-structure of 2880 bytes [23040 bits], and while I don't
> anticipate this being an issue, something that might be relevant.)

Ada.Sequential_IO and Ada.Direct_IO can both be instantiated with types
of any size, so you could simply use a 2880 character String, or a 2880
element Storage_Element_Array (remember to assert that
Storage_Element'Size = 8).

Greetings,

Jacob
-- 
»Verbing weirds language.«                         -- Calvin

^ permalink raw reply	[relevance 5%]

* Re: How To Write A Record To File ?
  2017-12-08 16:57  5%     ` Anh Vo
@ 2017-12-08 17:11  0%       ` Anh Vo
  0 siblings, 0 replies; 130+ results
From: Anh Vo @ 2017-12-08 17:11 UTC (permalink / raw)


On Friday, December 8, 2017 at 8:57:24 AM UTC-8, Anh Vo wrote:
> On Friday, December 8, 2017 at 8:41:57 AM UTC-8, pat...@spellingbeewinnars.org wrote:
> > Hi Adamagica
> > 
> > Please see this failing program:
> > 
> > -Patrick
> > 
> >        with sequential_io ;
> >        procedure compute_total_population is
> >         type foo_type is
> >         record
> >           moo              : integer ;
> >           boo              : integer ;
> >         end record ;
> >  
> >         foo                : foo_type ;
> >        -- will fail here with error:
> >        -- expect valid subtype mark to instantiate "Element_Type"
> >         package si is        new sequential_io(foo);
> 
> Your basic is error to instantiate with an object of record instead of record type. Here is the correct instantiation.
> 
>    package SI is new Ada.Sequential_IO (Foo_Type);
> 
> Anh Vo

I meant "your basic error is to ... "

^ permalink raw reply	[relevance 0%]

* Re: How To Write A Record To File ?
  @ 2017-12-08 16:57  5%     ` Anh Vo
  2017-12-08 17:11  0%       ` Anh Vo
  0 siblings, 1 reply; 130+ results
From: Anh Vo @ 2017-12-08 16:57 UTC (permalink / raw)


On Friday, December 8, 2017 at 8:41:57 AM UTC-8, pat...@spellingbeewinnars.org wrote:
> Hi Adamagica
> 
> Please see this failing program:
> 
> -Patrick
> 
>        with sequential_io ;
>        procedure compute_total_population is
>         type foo_type is
>         record
>           moo              : integer ;
>           boo              : integer ;
>         end record ;
>  
>         foo                : foo_type ;
>        -- will fail here with error:
>        -- expect valid subtype mark to instantiate "Element_Type"
>         package si is        new sequential_io(foo);

Your basic is error to instantiate with an object of record instead of record type. Here is the correct instantiation.

   package SI is new Ada.Sequential_IO (Foo_Type);

Anh Vo

^ permalink raw reply	[relevance 5%]

* Re: quiz for Sequential_IO Read
  2017-09-03 12:43  0%   ` Frank Buss
@ 2017-09-03 13:11  0%     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 130+ results
From: Dmitry A. Kazakov @ 2017-09-03 13:11 UTC (permalink / raw)


On 2017-09-03 14:43, Frank Buss wrote:
> On 09/03/2017 02:26 PM, Dmitry A. Kazakov wrote:
>> On 2017-09-03 13:01, Frank Buss wrote:
>>> What does this program output?
>>
>> Garbage.
>>
>>> with Ada.Sequential_IO;
>>> with Ada.Text_IO; use Ada.Text_IO;
>>>
>>> procedure Hello is
>>>
>>>     type Byte is range 0..255;
>>>
>>>     package Byte_IO is new Ada.Sequential_IO(Byte);
>>
>> Ada.Streams.Stream_IO is for the purpose.
>>
>> (Sequential_IO is practically never used)
> 
> I started learning Ada today,

Great!

> where can I read about good coding 
> practice, and how would the example look like with Stream_IO, and maybe 
> even a correct version?
> 
> I read about Sequential_IO in the Ada Programming wikibook, where it is 
> recommended for homogeneous binary data:
> 
> https://en.wikibooks.org/wiki/Ada_Programming/Input_Output

Well, Sequential_IO is not recommended because:

1. It would make your program non-portable;
2. It would hinder interoperability with programs written on other 
languages;
3. It requires homogeneous data, which is never the case in real life
4. It limits I/O to files

In practice Stream I/O is a better choice. You also should not use 
compiler-generated serialization attributes (see T'Read, T'Write, 
T'Input, T'Output attributes). These are not portable either. You should 
always replace them with your own.

P.S. Sequential_IO was introduced in Ada 83. A lot of things changed 
since then.

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

^ permalink raw reply	[relevance 0%]

* Re: quiz for Sequential_IO Read
  2017-09-03 12:26  0% ` Dmitry A. Kazakov
@ 2017-09-03 12:43  0%   ` Frank Buss
  2017-09-03 13:11  0%     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 130+ results
From: Frank Buss @ 2017-09-03 12:43 UTC (permalink / raw)


On 09/03/2017 02:26 PM, Dmitry A. Kazakov wrote:
> On 2017-09-03 13:01, Frank Buss wrote:
>> What does this program output?
>
> Garbage.
>
>> with Ada.Sequential_IO;
>> with Ada.Text_IO; use Ada.Text_IO;
>>
>> procedure Hello is
>>
>>     type Byte is range 0..255;
>>
>>     package Byte_IO is new Ada.Sequential_IO(Byte);
>
> Ada.Streams.Stream_IO is for the purpose.
>
> (Sequential_IO is practically never used)

I started learning Ada today, where can I read about good coding 
practice, and how would the example look like with Stream_IO, and maybe 
even a correct version?

I read about Sequential_IO in the Ada Programming wikibook, where it is 
recommended for homogeneous binary data:

https://en.wikibooks.org/wiki/Ada_Programming/Input_Output

-- 
Frank Buss, http://www.frank-buss.de
electronics and more: http://www.youtube.com/user/frankbuss

^ permalink raw reply	[relevance 0%]

* Re: quiz for Sequential_IO Read
  2017-09-03 11:01  6% quiz for Sequential_IO Read Frank Buss
@ 2017-09-03 12:26  0% ` Dmitry A. Kazakov
  2017-09-03 12:43  0%   ` Frank Buss
  0 siblings, 1 reply; 130+ results
From: Dmitry A. Kazakov @ 2017-09-03 12:26 UTC (permalink / raw)


On 2017-09-03 13:01, Frank Buss wrote:
> What does this program output?

Garbage.

> with Ada.Sequential_IO;
> with Ada.Text_IO; use Ada.Text_IO;
> 
> procedure Hello is
> 
>     type Byte is range 0..255;
> 
>     package Byte_IO is new Ada.Sequential_IO(Byte);

Ada.Streams.Stream_IO is for the purpose.

(Sequential_IO is practically never used)

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

^ permalink raw reply	[relevance 0%]

* quiz for Sequential_IO Read
@ 2017-09-03 11:01  6% Frank Buss
  2017-09-03 12:26  0% ` Dmitry A. Kazakov
  0 siblings, 1 reply; 130+ results
From: Frank Buss @ 2017-09-03 11:01 UTC (permalink / raw)


What does this program output?


with Ada.Sequential_IO;
with Ada.Text_IO; use Ada.Text_IO;

procedure Hello is

    type Byte is range 0..255;

    package Byte_IO is new Ada.Sequential_IO(Byte);
    A : Byte;
    B : Byte;
    C : Byte;
    File : Byte_IO.File_Type;

begin
    Byte_IO.Open(File, Byte_IO.In_File, "test.txt");
    Byte_IO.Read(File, A);
    Put_Line(Byte'Image(A));
    Byte_IO.Read(File, B);
    Put_Line(Byte'Image(B));
    C := (A mod 2) + (B mod 2);
    Put_Line(Byte'Image(C));
    Byte_IO.Close(File);
end;


The content of test.txt is just the ASCII string "hello":

hexdump -C test.txt:
00000000  68 65 6c 6c 6f                                    |hello|
00000005

Answer without compiling and running it! A hex calculator is allowed. 
Extra brownie point if you can explain the result :-)

Don't know if it matters, compiled with "gnatgcc (Debian 6.3.0-18) 6.3.0 
20170516", 64 bit version, and "-g -O2" command line options.

-- 
Frank Buss, http://www.frank-buss.de
electronics and more: http://www.youtube.com/user/frankbuss


^ permalink raw reply	[relevance 6%]

* Re: How to write "Hello" to a text file without a line terminator
  2016-08-14  8:30  7%                 ` Simon Wright
@ 2016-08-14 13:28  5%                   ` AdaMagica
  0 siblings, 0 replies; 130+ results
From: AdaMagica @ 2016-08-14 13:28 UTC (permalink / raw)


Am Sonntag, 14. August 2016 10:30:15 UTC+2 schrieb Simon Wright:
> Come to think of it, what would the use case be for instantiating
> Sequential (or Direct) IO with an unconstrained type? they both have
> only procedural forms for Read, so how could you ever retrieve a value?

No problem for a type like this (without the defaulted discriminant, you'll have indeed a problem, as for strings):

  type Disc is (A, B, C, D);
  type Rec (X: Disc := A) is record
    case X is
      when A => I: Integer;
      when B => F: Float;
      when C => B: Boolean;
      when D => null;
    end case;
  end record;

  package Req_Sequential_IO is new Ada.Sequential_IO (Rec);
  use Req_Sequential_IO;
  
  procedure Create is
    f:file_Type;
  begin
    create(f,out_file,"Rec");
    Write (f, (A, 42));
    Write (f, (C, False));
    Write (f, (X=>D));
    write (f, (B, -42.0));
    close(f);
  end Create;

  procedure Read is
    f:file_Type;
    R: Rec;
  begin
    open(f,in_file,"Rec");
    loop
      Read(f,R);
      exit when End_of_File(f);
    end loop;
    close(f);
  end Read;


^ permalink raw reply	[relevance 5%]

* Re: How to write "Hello" to a text file without a line terminator
  @ 2016-08-14  8:30  7%                 ` Simon Wright
  2016-08-14 13:28  5%                   ` AdaMagica
  0 siblings, 1 reply; 130+ results
From: Simon Wright @ 2016-08-14  8:30 UTC (permalink / raw)


AdaMagica <christ-usch.grein@t-online.de> writes:

> Am Samstag, 13. August 2016 20:03:51 UTC+2 schrieb Jeffrey R. Carter:
>> $ ./str_seq_io
>>  32
>> $ hd junk
>> 00000000  06 00 00 00 00 00 00 00  61 62 63 64 65 66        |........abcdef|
> ???? -- Letters 'A' through 'Z' are at positions 65 through 90 ????

'hd' is (probably) Carter's alias for 'hexdump -C' - the values are in
hex. And, those are letters 'a' .. 'z', not 'A' .. 'Z'.

>> 0000000e
> [...]
> But what's 00000000 and 0000000e?

The (hex) offsets within the file.

> Obviously on your 64-bit machine, length is output in 64 bits,
> although Integer has only 32.

Come to think of it, what would the use case be for instantiating
Sequential (or Direct) IO with an unconstrained type? they both have
only procedural forms for Read, so how could you ever retrieve a value?

GNAT has

   package Ada.Sequential_IO is

      pragma Compile_Time_Warning
        (Element_Type'Has_Access_Values,
         "Element_Type for Sequential_IO instance has access values");

      pragma Compile_Time_Warning
        (Element_Type'Has_Tagged_Values,
         "Element_Type for Sequential_IO instance has tagged values");

so should we ask for GNAT to do similar with "not
Element_Type'Constrained"? (use of 'Constrained with a type is a GNAT
extension).


^ permalink raw reply	[relevance 7%]

* Re: How to write "Hello" to a text file without a line terminator
  2016-08-13  9:12  0%           ` AdaMagica
@ 2016-08-13 18:03  6%             ` Jeffrey R. Carter
    0 siblings, 1 reply; 130+ results
From: Jeffrey R. Carter @ 2016-08-13 18:03 UTC (permalink / raw)


On 08/13/2016 02:12 AM, AdaMagica wrote:
> 
> No, it's not spaces, it's the length of the string output: Since (on my machine), Integer'Size=32, it's four bytes.
> Let'say, yout output
>   Write (f, "abcdef");
> You'll get (in bytes):
>   6 0 0 0 97 98 99 100 101 102
> And for a length of 256, you'll get:
>   0 1 0 0 ...

I was thinking 2 4-byte bounds, but on my 64-bit machine with 32-bit Integer, I
get a 6 followed by 7 zeros:

with Ada.Sequential_IO;
with Ada.Text_IO;

procedure Str_Seq_IO is
   package Str_IO is new Ada.Sequential_IO (Element_Type => String);

   File : Str_IO.File_Type;
begin -- Str_Seq_IO
   Ada.Text_IO.Put_Line (Item => Integer'Image (Integer'Size) );
   Str_IO.Create (File => File, Mode => Str_IO.Out_File, Name => "junk");
   Str_IO.Write (File => File, Item => "abcdef");
   Str_IO.Close (File => File);
end Str_Seq_IO;

$ ./str_seq_io
 32
$ hd junk
00000000  06 00 00 00 00 00 00 00  61 62 63 64 65 66        |........abcdef|
0000000e

-- 
Jeff Carter
"Who wears beige to a bank robbery?"
Take the Money and Run
144


^ permalink raw reply	[relevance 6%]

* Re: How to write "Hello" to a text file without a line terminator
  2016-08-13  4:23  0%         ` Jeffrey R. Carter
@ 2016-08-13  9:12  0%           ` AdaMagica
  2016-08-13 18:03  6%             ` Jeffrey R. Carter
  0 siblings, 1 reply; 130+ results
From: AdaMagica @ 2016-08-13  9:12 UTC (permalink / raw)


Am Samstag, 13. August 2016 06:23:16 UTC+2 schrieb Jeffrey R. Carter:
> On 08/12/2016 08:21 PM, Jerry wrote:
> > 
> > Using Ada.Sequential_IO instantiated for String puts out eight spaces before Hello or longer strings.
> 
> Are you sure they're spaces?

No, it's not spaces, it's the length of the string output: Since (on my machine), Integer'Size=32, it's four bytes.
Let'say, yout output
  Write (f, "abcdef");
You'll get (in bytes):
  6 0 0 0 97 98 99 100 101 102
And for a length of 256, you'll get:
  0 1 0 0 ...

^ permalink raw reply	[relevance 0%]

* Re: How to write "Hello" to a text file without a line terminator
  2016-08-13  3:21  7%       ` Jerry
@ 2016-08-13  4:23  0%         ` Jeffrey R. Carter
  2016-08-13  9:12  0%           ` AdaMagica
  0 siblings, 1 reply; 130+ results
From: Jeffrey R. Carter @ 2016-08-13  4:23 UTC (permalink / raw)


On 08/12/2016 08:21 PM, Jerry wrote:
> 
> Using Ada.Sequential_IO instantiated for String puts out eight spaces before Hello or longer strings.

Are you sure they're spaces?

-- 
Jeff Carter
"Pray that there's intelligent life somewhere up in
space, 'cause there's bugger all down here on earth."
Monty Python's Meaning of Life
61


^ permalink raw reply	[relevance 0%]

* Re: How to write "Hello" to a text file without a line terminator
  2016-08-12 17:34  4%     ` Jeffrey R. Carter
@ 2016-08-13  3:21  7%       ` Jerry
  2016-08-13  4:23  0%         ` Jeffrey R. Carter
  0 siblings, 1 reply; 130+ results
From: Jerry @ 2016-08-13  3:21 UTC (permalink / raw)


On Friday, August 12, 2016 at 10:34:19 AM UTC-7, Jeffrey R. Carter wrote:
> 
> To obtain a file without a final EOL, you can use streams, as suggested, or
> instantiate Ada.Sequential_IO for Character, which will require that you output
> your Characters individually.

Using Ada.Sequential_IO with Character works and seems easier than using Streams.

Using Ada.Sequential_IO instantiated for String puts out eight spaces before Hello or longer strings.
> 
> However, I don't know any portable way to write to standard output without
> adding an EOL. Any output involving Ada.Text_IO.Standard_Output will invoke
> Close when the file is finalized.
> 
That's OK for me, as I need to only write to an actual text file.

Thanks, everybody!

Jerry


^ permalink raw reply	[relevance 7%]

* Re: How to write "Hello" to a text file without a line terminator
  @ 2016-08-12 17:34  4%     ` Jeffrey R. Carter
  2016-08-13  3:21  7%       ` Jerry
  0 siblings, 1 reply; 130+ results
From: Jeffrey R. Carter @ 2016-08-12 17:34 UTC (permalink / raw)


On 08/12/2016 12:44 AM, Jerry wrote:
> 
> Both of these programs put a line terminator after Hello.
> 
> with Ada.Text_IO; use Ada.Text_IO;
> procedure test_ada_eol is
> begin
> Put("Hello");
> end test_ada_eol;
> 
> 
> with Ada.Text_IO; use Ada.Text_IO;
> procedure test_ada_eol_to_file is
>    Test_Ada_EOL_File : Ada.Text_IO.File_Type;
> begin
>    Create(Test_Ada_EOL_File, Out_File, "Test Ada EOL.txt");    
>    Put(Test_Ada_EOL_File, "Hello");
>    Close(Test_Ada_EOL_File);
> end test_ada_eol_to_file;

As Wright has pointed out, Close is defined to add a line terminator if the file
does not end with one. This explains the EOL for Test_Ada_Eol_To_File. In
Test_Ada_Eol, you have no call to Close. However, you'll note that File_Type is
defined as needing finalization [ARM A.10.1(86/2)]. While the effect of this
finalization is not defined, it's common to use it to close an open file. Every
Ada compiler I've used has done so. So this is probably the source of the EOL in
Test_Ada_Eol.

To obtain a file without a final EOL, you can use streams, as suggested, or
instantiate Ada.Sequential_IO for Character, which will require that you output
your Characters individually.

However, I don't know any portable way to write to standard output without
adding an EOL. Any output involving Ada.Text_IO.Standard_Output will invoke
Close when the file is finalized.

-- 
Jeff Carter
"Sons of a silly person."
Monty Python & the Holy Grail
02

^ permalink raw reply	[relevance 4%]

* Re: xor
  2012-03-25 19:26  4%     ` xor Niklas Holsti
@ 2012-03-27 20:09  0%       ` Michael Moeller
  0 siblings, 0 replies; 130+ results
From: Michael Moeller @ 2012-03-27 20:09 UTC (permalink / raw)




On Sun, 25 Mar 2012, Niklas Holsti wrote:

> On 12-03-25 18:16 , Michael Moeller wrote:
>> Thank you for your quick answer.
>> 
>> Can I use Unsigned_Byte_T to read in a byte from a file
>> as in C? I haven't looked into this yet.
>
> C has several ways to "read in a byte from a file", depending on the type of 
> the file and how you specify which byte you want to read. Can you be more 
> specific?

I have to read in what in C is called an unsigned byte, which in fact is
a stream of bytes without any interpretation as a symbol. Just a number
from 0 to 255.

In addition it would be nice to call something like 'fstat' to get the 
size of file in advance instead of checking every byte for EOF.

>
> If you mean reading an 8-bit octet from a "binary file" -- that is, not a 
> text file -- you can use the Ada library packages Ada.Sequential_IO or 
> Ada.Direct_IO, depending on your needs. These are generic packages, so you 
> must instantiate them for the type of data, for example Unsigned_Byte_T.
>
> If the file contains a mixture of different kinds of "binary" data, for 
> example both 8-bit data and 16-bit data, or more complex structures, you 
> should use the Ada "stream" facility from Ada.Streams.Stream_IO. The stream 
> facility helps you handle things like different endianness, padding, packing, 
> unusual encodings, and so on.
>
> The stream facility does not use generics; instead, it uses a combination of 
> tagged types and the special "stream attribute" operations T'Read, T'Write, 
> et cetera, which you can define differently for each type, T, that is present 
> in your file. For example, your 'Read operation for a 16-bit integer will 
> specify whether the integer is stored in little-endian or big-endian order in 
> the file (by reading two 8-bit integers, using 'Read for the 8-bit type, in 
> the corresponding order).
>
> The stream technique takes a bit of study to understand, but it works very 
> well, especially if the file has a mixture of different complex structures of 
> data, or if the file is created by a different language or computer and is 
> not in the "native" form for your Ada compiler.
>
> -- 
> Niklas Holsti
> Tidorum Ltd
> niklas holsti tidorum fi
>      .      @       .
>
Perhaps it will be more save to leave the C-procedures alone and to
call them from within Ada instead. I don't know whether this will be 
easier. However, I'll give Sequential_IO and Direct_IO a try.

Regards,
Michael




^ permalink raw reply	[relevance 0%]

* Re: xor
  @ 2012-03-25 19:26  4%     ` Niklas Holsti
  2012-03-27 20:09  0%       ` xor Michael Moeller
  0 siblings, 1 reply; 130+ results
From: Niklas Holsti @ 2012-03-25 19:26 UTC (permalink / raw)


On 12-03-25 18:16 , Michael Moeller wrote:
> Thank you for your quick answer.
>
> Can I use Unsigned_Byte_T to read in a byte from a file
> as in C? I haven't looked into this yet.

C has several ways to "read in a byte from a file", depending on the 
type of the file and how you specify which byte you want to read. Can 
you be more specific?

If you mean reading an 8-bit octet from a "binary file" -- that is, not 
a text file -- you can use the Ada library packages Ada.Sequential_IO or 
Ada.Direct_IO, depending on your needs. These are generic packages, so 
you must instantiate them for the type of data, for example Unsigned_Byte_T.

If the file contains a mixture of different kinds of "binary" data, for 
example both 8-bit data and 16-bit data, or more complex structures, you 
should use the Ada "stream" facility from Ada.Streams.Stream_IO. The 
stream facility helps you handle things like different endianness, 
padding, packing, unusual encodings, and so on.

The stream facility does not use generics; instead, it uses a 
combination of tagged types and the special "stream attribute" 
operations T'Read, T'Write, et cetera, which you can define differently 
for each type, T, that is present in your file. For example, your 'Read 
operation for a 16-bit integer will specify whether the integer is 
stored in little-endian or big-endian order in the file (by reading two 
8-bit integers, using 'Read for the 8-bit type, in the corresponding order).

The stream technique takes a bit of study to understand, but it works 
very well, especially if the file has a mixture of different complex 
structures of data, or if the file is created by a different language or 
computer and is not in the "native" form for your Ada compiler.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



^ permalink raw reply	[relevance 4%]

* Re: Encapsulating Ada.Direct_IO
  2010-11-18  2:21  5%     ` Peter C. Chapin
@ 2010-11-18 16:36  0%       ` Adam Beneschan
  0 siblings, 0 replies; 130+ results
From: Adam Beneschan @ 2010-11-18 16:36 UTC (permalink / raw)


On Nov 17, 6:21 pm, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
> On 2010-11-17 20:16, Randy Brukardt wrote:
>
> > Surely not. Not all machines have 8-bits as any sort of native type. For
> > instance, the Unisys U2200 (a 36-bit machine, with 9-bit bytes) used
> > Character'Size = 9. (It was great fun for the cross-compiler.)
>
> So in that case if you absolutely wanted to read 8 bit units from a file
> (because the file is in some externally defined binary format that uses
> 8 bit units) it would be necessary to do something like:
>
> type My_Byte is mod 2**8;
> for My_Byte'Size use 8;   -- This is important.
>
> package My_Byte_IO is new Ada.Sequential_IO(My_Byte);
>
> ... and then convert from My_Byte to Character only as appropriate
> during the file decoding process.
>
> True?

I have a longish rant that touches on this, but the short answer is
that I don't think there's an Ada answer to your question.  If you had
a file defined as using 8-bit units, and that file got put onto a
system that uses 36-bit words, you'd need to know just what the OS is
going to do with it, and how the particular Ada implementation will
deal with files on that OS.  It may be that the native "read from
file" service on that OS will put each byte into a 9-bit byte and zero
the high bit.  I don't see how to avoid implementation-dependent code
in a case like this.

                                       -- Adam



^ permalink raw reply	[relevance 0%]

* Re: Encapsulating Ada.Direct_IO
  @ 2010-11-18  2:21  5%     ` Peter C. Chapin
  2010-11-18 16:36  0%       ` Adam Beneschan
  0 siblings, 1 reply; 130+ results
From: Peter C. Chapin @ 2010-11-18  2:21 UTC (permalink / raw)


On 2010-11-17 20:16, Randy Brukardt wrote:

> Surely not. Not all machines have 8-bits as any sort of native type. For 
> instance, the Unisys U2200 (a 36-bit machine, with 9-bit bytes) used 
> Character'Size = 9. (It was great fun for the cross-compiler.)

So in that case if you absolutely wanted to read 8 bit units from a file
(because the file is in some externally defined binary format that uses
8 bit units) it would be necessary to do something like:

type My_Byte is mod 2**8;
for My_Byte'Size use 8;   -- This is important.

package My_Byte_IO is new Ada.Sequential_IO(My_Byte);

... and then convert from My_Byte to Character only as appropriate
during the file decoding process.

True?

Peter



^ permalink raw reply	[relevance 5%]

* Re: Binary opperations under Ada?
  @ 2010-08-21  0:17  5% ` Jeffrey Carter
  0 siblings, 0 replies; 130+ results
From: Jeffrey Carter @ 2010-08-21  0:17 UTC (permalink / raw)


On 08/20/2010 04:23 PM, Trogdor wrote:
>
> -) I want to read in a raw binary file and perform bit manipulation
> on the data.
>
> -) I vaguely remember seeing a post about a module package for low
> level stuff, cut han no longer find it in the group.

For I/O, you may be thinking of seqeuntial or direct I/O, or streams. You can 
find the packages Ada.Sequential_IO, Ada.Direct_IO, and Ada.Streams.Stream_IO in 
the ARM, Annex A, which is quite readable:

http://www.adaic.org/standards/05rm/html/RM-TOC.html

For bit manipulation, you can use (packed) arrays of Boolean or modular types. 
The former existed in Ada 83 and the latter were introduced in Ada 95; both 
should be covered in any good text.

But it's better to talk about what you want to do than how you think you should 
do it. Sometimes you might find a better way to do something.


"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---



^ permalink raw reply	[relevance 5%]

* Re: Preferred way to do binray I/O on standard input/output stream
  @ 2009-10-24 22:57  5% ` Jeffrey R. Carter
  0 siblings, 0 replies; 130+ results
From: Jeffrey R. Carter @ 2009-10-24 22:57 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:
> 
> There is no kind of binary mode vs text mode flags with Ada stream/
> file IO, as it there are with C. And then, C files are not typed,
> while Ada files/streams are, thus, this will not make any sense to
> simply talk about binary I/O with Ada. So let simply talk about non-
> text I/O from and to standard input/output.
> 
> When some people need this, what is the typical preferred to do so ?

Package Ada.Text_IO.Text_Streams (ARM A.12.2) allows converting 
Ada.Text_IO.File_Type to Stream_Access and reading and writing them through the 
capabilities of streams. This allows converting standard input and output to 
Stream_Access, since Ada.Text_IO provides the functions Standard_Input and 
Standard_Output which return Ada.Text_IO.File_Type.

For general binary I/O, one can use Ada.Sequential_IO or Ada.Direct_IO 
instantiated with an appropriate type, or Ada.Streams.Stream_IO. For standard 
input and output, however, this can only work if you have a name for these files 
that you can use to open them, and such a name is platform-dependent. The only 
independent way to access these files is through streams and 
Ada.Text_IO.Text_Streams.

-- 
Jeff Carter
"Drown in a vat of whiskey. Death, where is thy sting?"
Never Give a Sucker an Even Break
106



^ permalink raw reply	[relevance 5%]

* Re: Generalized serialization for enumeration types
  @ 2009-08-26 11:17  6% ` Georg Bauhaus
  0 siblings, 0 replies; 130+ results
From: Georg Bauhaus @ 2009-08-26 11:17 UTC (permalink / raw)


xorque schrieb:
> Hello.
> 
> I'm designing a package that uses a lot of similar but distinct
> enumeration types.
> 
> At some point, those types need to be encoded to be sent over
> the wire. The encoding rules are simple:
> 
>   The enumeration values are converted to unsigned 32 bit
>   integers with the first value as 0 and increasing sequentially
>   with each new value. The 32 bit value is packed into big-endian
>   byte order.
> 
> The problem is: With so many enumeration types, I now have about 300
> lines of almost identical procedures (to be used as stream attributes)
> that just call a procedure that packs Unsigned_32 values into
> Storage_Element arrays.

Not exactly the same solution, but there doesn't seem to be
a problem with a generic and Seuqential_IO; I might well
have misunderstood.

There is a #Gem at AdaCors's web site explaining how
to use different representations for types derived from
e.g. enum types, if that is any help.

package Enums is

   type Color is (Red, Green, Blue);
   type Smell is (Good, Neutral, Bad);
private
   for Smell use (Good => 14, Neutral => 23, Bad => 100);
   for Smell'size use 32;
   for Color'size use 32;
end Enums;

generic
   type E is (<>);
procedure EG(extension : String);

with Ada.Sequential_IO;
with Interfaces;  use Interfaces;
with Ada.Unchecked_Conversion;

procedure EG(extension : String) is
   package My_IO is new Ada.Sequential_IO(Unsigned_32);
   function To_Unsigned_32 is new Ada.Unchecked_Conversion
      (Source => E, Target => Unsigned_32);
   F : My_IO.File_Type;
begin
   My_IO.Create(F, My_IO.Out_File, "run." & extension);
   for K in E loop
      My_IO.Write(F, Item => To_Unsigned_32 (K));
   end loop;
end EG;

with Enums, EG;
procedure Run is
   use Enums;
   procedure Color_Out is new EG(Color);
   procedure Smell_Out is new EG(Smell);
begin
   Color_Out("rgb");
   Smell_Out("snf");
end Run;



^ permalink raw reply	[relevance 6%]

* Re: Ada extension information
  2009-05-30  7:13  3% ` anon
@ 2009-05-30 10:13  0%   ` info
  0 siblings, 0 replies; 130+ results
From: info @ 2009-05-30 10:13 UTC (permalink / raw)


On May 30, 8:13 am, a...@anon.org (anon) wrote:
> The problem is, those extra routines that make use of the "C like conditional
> compiling statements" are define in the body and referenced in the private
> sections of "Ada.Text_IO" and "Ada.Wide_Text_IO" packages. The comments
> state that they are for a sub-package "Ada.Text_IO.Wide_Text_IO" that is not
> present in the source. In scanning all 2850 plus files in the 2009 GNAT, the
> only references to this sub-package is in comments from the following 3 files:
>
>   Ada.Text_IO
>   Ada.Wide_Text_IO
> and
>   System.WCh_WtS
>
> So, why are these routines in the two Text IO packages, and where is that
> child package "Ada.Text_IO.Wide_Text_IO"?  
>
> Now, if these routines are defined and reference only with-in the package
> they are defined, then why are these routines references in the specification
> private area, they should be at the top of the body, hidden from the
> specification side. Keeping the Ada Text packages more precise to the Ada
> language, instead of junking it up with references that are not used outside
> ofthat package.  
>
> Or is this somewhat of an advance copy of 2010/2011 version of
> Ada.Text_IO and a new "Ada.Text_IO.Wide_Text_IO" package.
>
> And there is no reference in the documentation of the "C like conditional
> compiling statements".
>
> From RM 1.1.3 "Conformity of an Implementation with the Standard"
>
>     6  Contain no variations except those explicitly permitted by this
>        International Standard, or those that are impossible or
>        impractical to avoid given the implementation's execution
>        environment;
>
>     7  Specify all such variations in the manner prescribed by this
>        International Standard.
>
> No True Ada programmer wants "Language extensions" without references.  
> And most would prefer some simple references that is stated with-in the RM,
> not just hinted to by the RM, like having a RM section on what type
> "conditional compiling statements" would be acceptable with a few examples.
>
> So where is the documentation that is requred by RM 1.1.3 ( 7 ). Plus,
> I have not found where "conditional compiling statements" are allow
> in Ada RM 1.1.3 ( 6 ). And in some cases "conditional compiling
> statements" kills the need for generic package.
>
> Plus, there is another Adacore pragma ( sample located in body of
> Ada.Sequential_IO ). This seams to bypass the requirement to use
> "-gnatX".
>
>       pragma Extensions_Allowed ( On | Off ) ;
>
> with no documentation in the GNAT Documentation User's Guide ( GNAT_UGN )
> or the GNAT Reference Manual ( GNAT_RM ).
>
> Plus, if Adacore want to extend Ada, they normally use a child package
> with-in the GNAT package structure to test the idea before forcing the
> changes into the the Ada package structure.
>
> And finally what other changes have been made and how to disable them. Aka
> to turn off all "conditional expressions"? And for that reason the "C like
> conditional compiling statements" should never be in the core Ada or core
> System packages that are define in the RM.
>
> In <d784432e-fa9d-4bc9-b849-ecb2208af...@c9g2000yqm.googlegroups.com>, i...@midoan.com writes:
> >Hello,
> >a-textio.adb released with GNAT 2009 GPL for windows, contains:
>
> >Item :=
> >              (if not Is_Start_Of_Encoding (Character'Val (ch),
> >File.WC_Method)
> >               then Character'Val (ch)
> >               else Get_Upper_Half_Char_Immed (Character'Val (ch),
> >File));
>
> >which is easy enough to understand but is not standard Ada.
>
> >GNAT 2009 tells me :
>
> >try.adb:5:09: conditional expression is an Ada extension
> >try.adb:5:09: use -gnatX switch to compile this unit
>
> >http://www.adacore.com/2009/03/29/NF-63-I317-009-gnat/discusses
> >this.
>
> >Is it not jumping the gun a little to use these extensions to document
> >standard libraries before they become official, or even documented?
>
> >More specifically where are these Ada extensions formally documented?
> >(Ada Conformity Assessment Authority seem to have discussion about
> >this up to 15th March 2009 !)
>
> >PS In the meantime Mika is broken if you use a-textio as distributed
> >with GNAT GPL  2009.
>
> >Sincerely,
> >http://www.midoan.com
>
>

Just to clarify what Mika, our test data generator, uniquely it
appears, does. During test data generation, and only if the user's
code uses standrad libraries, Mika analyses the standard libraries and
uses that information to simulate their behaviour. We believe that
this approach is more accurate, repeatable and thorough than other
alternatives such as writing manual stubs for them. It also offers the
possibility of generating more interesting tests that cover the CFG of
the standard libraries (not to test the standard libraries, but rather
to generate tests that are borderline and that may not be expected by
the developers).


It therefore makes our job easier if the libraries are written in
standard Ada. The fact that they are close to it is already a great
help for us: althought we cannot analyse everything, things left in
code during development (but would probably be removed in the final
version) such as usages of textio do not have to removed; the code
does not have to be modified.

We released a minor update yesterday, and Mika can now parse
conditional expressions in standard libraries.

Regards,
Midoan



^ permalink raw reply	[relevance 0%]

* Re: Ada extension information
  @ 2009-05-30  7:13  3% ` anon
  2009-05-30 10:13  0%   ` info
  0 siblings, 1 reply; 130+ results
From: anon @ 2009-05-30  7:13 UTC (permalink / raw)


The problem is, those extra routines that make use of the "C like conditional 
compiling statements" are define in the body and referenced in the private 
sections of "Ada.Text_IO" and "Ada.Wide_Text_IO" packages. The comments 
state that they are for a sub-package "Ada.Text_IO.Wide_Text_IO" that is not 
present in the source. In scanning all 2850 plus files in the 2009 GNAT, the 
only references to this sub-package is in comments from the following 3 files:

  Ada.Text_IO 
  Ada.Wide_Text_IO
and 
  System.WCh_WtS

So, why are these routines in the two Text IO packages, and where is that 
child package "Ada.Text_IO.Wide_Text_IO"?  

Now, if these routines are defined and reference only with-in the package 
they are defined, then why are these routines references in the specification 
private area, they should be at the top of the body, hidden from the 
specification side. Keeping the Ada Text packages more precise to the Ada 
language, instead of junking it up with references that are not used outside 
ofthat package.   

Or is this somewhat of an advance copy of 2010/2011 version of 
Ada.Text_IO and a new "Ada.Text_IO.Wide_Text_IO" package.


And there is no reference in the documentation of the "C like conditional 
compiling statements".

From RM 1.1.3 "Conformity of an Implementation with the Standard" 

    6  Contain no variations except those explicitly permitted by this
       International Standard, or those that are impossible or
       impractical to avoid given the implementation's execution
       environment;

    7  Specify all such variations in the manner prescribed by this
       International Standard.


No True Ada programmer wants "Language extensions" without references.  
And most would prefer some simple references that is stated with-in the RM, 
not just hinted to by the RM, like having a RM section on what type 
"conditional compiling statements" would be acceptable with a few examples. 

So where is the documentation that is requred by RM 1.1.3 ( 7 ). Plus, 
I have not found where "conditional compiling statements" are allow 
in Ada RM 1.1.3 ( 6 ). And in some cases "conditional compiling 
statements" kills the need for generic package.

Plus, there is another Adacore pragma ( sample located in body of 
Ada.Sequential_IO ). This seams to bypass the requirement to use 
"-gnatX". 

      pragma Extensions_Allowed ( On | Off ) ;

with no documentation in the GNAT Documentation User's Guide ( GNAT_UGN ) 
or the GNAT Reference Manual ( GNAT_RM ).

Plus, if Adacore want to extend Ada, they normally use a child package 
with-in the GNAT package structure to test the idea before forcing the 
changes into the the Ada package structure. 

And finally what other changes have been made and how to disable them. Aka 
to turn off all "conditional expressions"? And for that reason the "C like 
conditional compiling statements" should never be in the core Ada or core 
System packages that are define in the RM.




In <d784432e-fa9d-4bc9-b849-ecb2208afc73@c9g2000yqm.googlegroups.com>, info@midoan.com writes:
>Hello,
>a-textio.adb released with GNAT 2009 GPL for windows, contains:
>
>Item :=
>              (if not Is_Start_Of_Encoding (Character'Val (ch),
>File.WC_Method)
>               then Character'Val (ch)
>               else Get_Upper_Half_Char_Immed (Character'Val (ch),
>File));
>
>which is easy enough to understand but is not standard Ada.
>
>GNAT 2009 tells me :
>
>try.adb:5:09: conditional expression is an Ada extension
>try.adb:5:09: use -gnatX switch to compile this unit
>
>http://www.adacore.com/2009/03/29/NF-63-I317-009-gnat/ discusses
>this.
>
>Is it not jumping the gun a little to use these extensions to document
>standard libraries before they become official, or even documented?
>
>More specifically where are these Ada extensions formally documented?
>(Ada Conformity Assessment Authority seem to have discussion about
>this up to 15th March 2009 !)
>
>PS In the meantime Mika is broken if you use a-textio as distributed
>with GNAT GPL  2009.
>
>Sincerely,
>http://www.midoan.com




^ permalink raw reply	[relevance 3%]

* Re: newbie problem
  2009-05-18 10:52  7%           ` Ludovic Brenta
@ 2009-05-18 11:09  0%             ` Olivier Scalbert
  0 siblings, 0 replies; 130+ results
From: Olivier Scalbert @ 2009-05-18 11:09 UTC (permalink / raw)


Ludovic Brenta wrote:

> Rename it Stereo_Amplitude_IO. (You don't yet have a package named
> Stereo_Amplitude, BTW). If you insist on making a package named
> Stereo_Amplitude.IO then you must put it at library level, i.e. not
> inside another package, like this:
> 
> -- stereo_amplitude.ads
> package Stereo_Amplitude is
> end Stereo_Amplitude;
> 
> -- stereo_amplitude-io.ads
> with Ada.Sequential_IO
> with Audio;
> package Stereo_Amplitude.IO is new Ada.Sequential_IO
> (Audio.Stereo_Amplitude);
> 
> but I fail to see the benefit of this.
> 
> --
> Ludovic Brenta.

Thanks Ludovic.

In fact in "package Stereo_Amplitude.Io" I have not noticed that a "_" 
has been transformed into a "." !
Cosmic particle ? Beaujolais effect ? I do not know ...
;-)

Olivier



^ permalink raw reply	[relevance 0%]

* Re: newbie problem
  2009-05-18 10:23  7%         ` Olivier Scalbert
  2009-05-18 10:48  0%           ` Martin
@ 2009-05-18 10:52  7%           ` Ludovic Brenta
  2009-05-18 11:09  0%             ` Olivier Scalbert
  1 sibling, 1 reply; 130+ results
From: Ludovic Brenta @ 2009-05-18 10:52 UTC (permalink / raw)


On May 18, 12:23 pm, Olivier Scalbert <olivier.scalb...@algosyn.com>
wrote:
> sjw wrote:
> > We proposed a (joke) coding standard that the length of a name should
> > be log-base-2 the length of its scope in lines. So I might be quite
> > happy with Output : File_Type; for example. Depends whether you have
> > anything else that might be confused with it.
>
> Hi,
>
> I have reorganized the code a little bit.
>
> ------------------------------------------
> -- audio.ads
> ------------------------------------------
> package audio is
>
>      type Amplitude is new Float;
>      type Frequency is new Float;
>      type Time      is new Float;
>
>      type Stereo_Amplitude is record
>          Left : Amplitude;
>          Right: Amplitude;
>      end record;
>
> end audio;
>
> ------------------------------------------
> -- audio-als.ads
> ------------------------------------------
> private with Ada.Sequential_Io;
>
> package audio.als is
>
> type File is limited private;
>
> procedure Create (F: out File; File_Name: String);
> procedure Write  (F: in  File; Sample: Stereo_Amplitude);
> procedure Close  (F: out File);
> procedure Get_Min_Max (File_Name: String; Min: out Amplitude; Max: out
> Amplitude);
>
> private
>
> package Stereo_Amplitude.Io is new Ada.Sequential_Io (Stereo_Amplitude);
>
> type File is record
>      File_Type: Stereo_Amplitude_Io.File_Type;
>      -- perhaps more stuff later
> end record;
>
> end audio.als;
>
> ------------------------------------------
> -- audio-als.adb
> ------------------------------------------
> ...
>
> When I do: gnatmake audio-als.adb, I've got:
>
> gnatmake audio-als.adb
> gcc-4.3 -c audio-als.adb
> audio-als.ads:14:09: child unit allowed only at library level
>
> line 14 is : package Stereo_Amplitude.Io is new Ada.Sequential_Io
> (Stereo_Amplitude);
>
> I must admit that I have no idea on how to solve it ...

Rename it Stereo_Amplitude_IO. (You don't yet have a package named
Stereo_Amplitude, BTW). If you insist on making a package named
Stereo_Amplitude.IO then you must put it at library level, i.e. not
inside another package, like this:

-- stereo_amplitude.ads
package Stereo_Amplitude is
end Stereo_Amplitude;

-- stereo_amplitude-io.ads
with Ada.Sequential_IO
with Audio;
package Stereo_Amplitude.IO is new Ada.Sequential_IO
(Audio.Stereo_Amplitude);

but I fail to see the benefit of this.

--
Ludovic Brenta.



^ permalink raw reply	[relevance 7%]

* Re: newbie problem
  2009-05-18 10:23  7%         ` Olivier Scalbert
@ 2009-05-18 10:48  0%           ` Martin
  2009-05-18 10:52  7%           ` Ludovic Brenta
  1 sibling, 0 replies; 130+ results
From: Martin @ 2009-05-18 10:48 UTC (permalink / raw)


On May 18, 11:23 am, Olivier Scalbert <olivier.scalb...@algosyn.com>
wrote:
> sjw wrote:
> > We proposed a (joke) coding standard that the length of a name should
> > be log-base-2 the length of its scope in lines. So I might be quite
> > happy with Output : File_Type; for example. Depends whether you have
> > anything else that might be confused with it.
>
> Hi,
>
> I have reorganized the code a little bit.
>
> ------------------------------------------
> -- audio.ads
> ------------------------------------------
> package audio is
>
>      type Amplitude is new Float;
>      type Frequency is new Float;
>      type Time      is new Float;
>
>      type Stereo_Amplitude is record
>          Left : Amplitude;
>          Right: Amplitude;
>      end record;
>
> end audio;
>
> ------------------------------------------
> -- audio-als.ads
> ------------------------------------------
> private with Ada.Sequential_Io;
>
> package audio.als is
>
> type File is limited private;
>
> procedure Create (F: out File; File_Name: String);
> procedure Write  (F: in  File; Sample: Stereo_Amplitude);
> procedure Close  (F: out File);
> procedure Get_Min_Max (File_Name: String; Min: out Amplitude; Max: out
> Amplitude);
>
> private
>
> package Stereo_Amplitude.Io is new Ada.Sequential_Io (Stereo_Amplitude);
>
> type File is record
>      File_Type: Stereo_Amplitude_Io.File_Type;
>      -- perhaps more stuff later
> end record;
>
> end audio.als;
>
> ------------------------------------------
> -- audio-als.adb
> ------------------------------------------
> ...
>
> When I do: gnatmake audio-als.adb, I've got:
>
> gnatmake audio-als.adb
> gcc-4.3 -c audio-als.adb
> audio-als.ads:14:09: child unit allowed only at library level
>
> line 14 is : package Stereo_Amplitude.Io is new Ada.Sequential_Io
> (Stereo_Amplitude);
>
> I must admit that I have no idea on how to solve it ...
>
> Olivier

Change

package Stereo_Amplitude.Io

to

package Stereo_Amplitude_Io

Cheers
-- Martin



^ permalink raw reply	[relevance 0%]

* Re: newbie problem
  @ 2009-05-18 10:23  7%         ` Olivier Scalbert
  2009-05-18 10:48  0%           ` Martin
  2009-05-18 10:52  7%           ` Ludovic Brenta
  0 siblings, 2 replies; 130+ results
From: Olivier Scalbert @ 2009-05-18 10:23 UTC (permalink / raw)


sjw wrote:
> We proposed a (joke) coding standard that the length of a name should
> be log-base-2 the length of its scope in lines. So I might be quite
> happy with Output : File_Type; for example. Depends whether you have
> anything else that might be confused with it.

Hi,

I have reorganized the code a little bit.

------------------------------------------
-- audio.ads
------------------------------------------
package audio is

     type Amplitude is new Float;
     type Frequency is new Float;
     type Time      is new Float;

     type Stereo_Amplitude is record
         Left : Amplitude;
         Right: Amplitude;
     end record;

end audio;

------------------------------------------
-- audio-als.ads
------------------------------------------
private with Ada.Sequential_Io;

package audio.als is

type File is limited private;

procedure Create (F: out File; File_Name: String);
procedure Write  (F: in  File; Sample: Stereo_Amplitude);
procedure Close  (F: out File);
procedure Get_Min_Max (File_Name: String; Min: out Amplitude; Max: out 
Amplitude);

private

package Stereo_Amplitude.Io is new Ada.Sequential_Io (Stereo_Amplitude);

type File is record
     File_Type: Stereo_Amplitude_Io.File_Type;
     -- perhaps more stuff later
end record;

end audio.als;

------------------------------------------
-- audio-als.adb
------------------------------------------
...

When I do: gnatmake audio-als.adb, I've got:

gnatmake audio-als.adb
gcc-4.3 -c audio-als.adb
audio-als.ads:14:09: child unit allowed only at library level

line 14 is : package Stereo_Amplitude.Io is new Ada.Sequential_Io 
(Stereo_Amplitude);

I must admit that I have no idea on how to solve it ...



Olivier

















^ permalink raw reply	[relevance 7%]

* Re: newbie problem
                     ` (2 preceding siblings ...)
  2009-05-13 18:00  6% ` Olivier Scalbert
@ 2009-05-14  2:59  5% ` anon
  3 siblings, 0 replies; 130+ results
From: anon @ 2009-05-14  2:59 UTC (permalink / raw)


In order to create a hidden structures, the easies is to insert the IO into the 
body, but you may have to create your own "File_Type" in the spec file.  But 
another version is to use extra files and packages to hide the IO. There are a 
few others ways but the more you try to hide a package or the operations of 
that package the more complex the Ada packages and structures can become.  

--
-- sound.ads  -- Type used in Sound.IO
--
package Sound is

  pragma Pure ( Sound ) ;

  type Amplitude_Type is new Float ;
  type Frequency_Type is new Float ;
  type Time_Type      is new Float ;

  type Stereo_Amplitude_Type is record
                               Left : Amplitude_Type ;
                               Right: Amplitude_Type ;
                             end record ;
end Sound ;
--
-- Sound-io.ads
--
with Ada.Sequential_IO ;

package Sound.IO is new Ada.Sequential_IO ( Stereo_Amplitude_Type ) ;

--------------------------------------
-- adasound.ads
--------------------------------------
with Sound ;
with Sound.IO ;

package AdaSound is

     procedure Als_Create ( Als_File  : in out Sound.IO.File_Type ; 
                            File_Name : String ) ;

     procedure Als_Write ( Als_File : in out Sound.IO.File_Type ; 
                           Value    : Sound.Stereo_Amplitude_Type ) ;

     procedure Als_Close  ( Als_File : in out Sound.IO.File_Type ) ;

end AdaSound ;
--------------------------------------
-- adasound.adb
--------------------------------------
with Sound ;
with Sound.IO ;

package body adasound is

  procedure Als_Create ( Als_File : in out Sound.IO.File_Type ; 
                         File_Name: String     ) is
      File : Sound.IO.File_Type ;
    begin
      Sound.IO.Create ( Als_File, Sound.IO.Out_File, File_Name ) ;
    end Als_Create ;

  procedure Als_Write ( Als_File : in out Sound.IO.File_Type ; 
                        Value    : Sound.Stereo_Amplitude_Type ) is
    begin
      Sound.IO.Write ( Als_File, Value ) ;
    end Als_Write ;

  procedure Als_Close ( Als_File: in out Sound.IO.File_Type ) is
    begin
      Sound.IO.Close ( Als_File ) ;
    end Als_Close ;
end adasound ;
--------------------------------------
-- driver.adb
--------------------------------------

with Sound ;
with Sound.IO ;

with AdaSound ;

procedure driver is
     Sample_Rate : constant Integer := 44_100 ;
     Nb_Seconds  : constant Integer :=  3_600 ;

     Als_File    : Sound.IO.File_Type ;
     Stereo      : Sound.Stereo_Amplitude_Type ;

begin
  Stereo.Left  := 0.0 ;
  Stereo.Right := 0.0 ;
  Als_Create ( Als_File, "test.als" ) ;
  for i in 1..Sample_Rate * Nb_Seconds loop
    Als_Write( Als_File, Stereo ) ;
  end loop ;
  Als_Close( Als_File ) ;
end driver;


In <4a0ad646$0$2854$ba620e4c@news.skynet.be>, Olivier Scalbert <olivier.scalbert@algosyn.com> writes:
>Hello,
>
>I am doing a little package and I have problems just for writing the 
>specification ...
>
>In short, this package should offer services to create sequential files 
>that store stereo sound samples.
>
>Here is the code:
>
>with Sequential_Io; -- Problem 2  not nice should be hidden but how ?
>
>package adasound is
>
>     type Amplitude_T is new Float;
>     type Frequency_T is new Float;
>     type Time_T      is new Float;
>
>     type Stereo_Amplitude_T is record
>         Left : Amplitude_T;
>         Right: Amplitude_T;
>     end record;
>
>     type Als_File_T is private;
>
>     function  Als_Create(File_Name: String) return Als_File_T;
>     procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude: 
>Stereo_Amplitude_T);
>     procedure Als_Close(Als_File: Als_File_T);
>
>private
>     package Stereo_Amplitude_Io is new Sequential_Io (Stereo_Amplitude_T);
>
>     type Als_File_T is record
>         File_Type: Stereo_Amplitude_Io.File_Type; -- Problem 1 !!
>         -- perhaps more stuff later
>     end record;
>
>end adasound;
>
>Problem 1: it does not compile !
>adasound.ads:23:10: completion of nonlimited type cannot be limited
>adasound.ads:23:10: component "File_Type" of type "Als_File_T" has 
>limited type
>
>Problem 2: how to avoid the first "with Sequential_Io;" ?
>
>Thanks to help me !
>
>Olivier.




^ permalink raw reply	[relevance 5%]

* Re: newbie problem
  2009-05-13 18:00  6% ` Olivier Scalbert
@ 2009-05-13 18:51  0%   ` Martin
    0 siblings, 1 reply; 130+ results
From: Martin @ 2009-05-13 18:51 UTC (permalink / raw)


On May 13, 7:00 pm, Olivier Scalbert <olivier.scalb...@algosyn.com>
wrote:
> Finally I have done some changes. Als_Create is now a procedure.
>
> Here is the code:
>
> --------------------------------------
> -- adasound.ads
> --------------------------------------
> private with Ada.Sequential_Io;
>
> package adasound is
>
>      type Amplitude_T is new Float;
>      type Frequency_T is new Float;
>      type Time_T      is new Float;
>
>      type Stereo_Amplitude_T is record
>          Left : Amplitude_T;
>          Right: Amplitude_T;
>      end record;
>
>      type Als_File_T is limited private;
>
>      procedure Als_Create(Als_File: out Als_File_T; File_Name: String);
>      procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude:
> Stereo_Amplitude_T);
>      procedure Als_Close(Als_File: out Als_File_T);
>
> private
>      package Stereo_Amplitude_Io is new Ada.Sequential_Io
> (Stereo_Amplitude_T);
>
>      type Als_File_T is record
>          File_Type: Stereo_Amplitude_Io.File_Type;
>          -- perhaps more stuff later
>      end record;
>
> end adasound;
>
> --------------------------------------
> -- adasound.adb
> --------------------------------------
> package body adasound is
>
> procedure Als_Create(Als_File: out Als_File_T; File_Name: String) is
>      File: Stereo_Amplitude_Io.File_Type;
> begin
>      Stereo_Amplitude_Io.Create(Als_File.File_Type,
> Stereo_Amplitude_Io.Out_File, File_Name);
> end Als_Create;
>
> procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude:
> Stereo_Amplitude_T) is
> begin
>      Stereo_Amplitude_Io.Write(Als_File.File_Type, Stereo_Amplitude);
> end Als_Write;
>
> procedure Als_Close(Als_File: out Als_File_T) is
> begin
>      Stereo_Amplitude_Io.Close(Als_File.File_Type);
> end Als_Close;
>
> end adasound;
>
> --------------------------------------
> -- driver.adb
> --------------------------------------
> with adasound;
> use adasound;
>
> procedure driver is
>      Als_File : Als_File_T;
>      Stereo : Stereo_Amplitude_T;
>      Sample_Rate : constant Integer := 44_100;
>      Nb_Seconds  : constant Integer :=  3_600;
> begin
>      Stereo.Left  := 0.0;
>      Stereo.Right := 0.0;
>      Als_Create(Als_File, "test.als");
>      for i in 1..Sample_Rate * Nb_Seconds loop
>          Als_Write(Als_File, Stereo);
>      end loop;
>      Als_Close(Als_File);
> end driver;
>
> I do not know if the design is better or not but at least it works.
>
> I am also very pleased with the performance. Of course, it is nearly
> only IO but ...
>
> time ./driver
> real    0m15.648s
> user    0m10.305s
> sys     0m3.364s
>
> ls -l test.als
> -rw-r--r-- 1 ols ols 1270080000 2009-05-13 18:41 test.als
>
> Olivier.

Nice one.

Stylistically, why isn't the package called 'ALS' and then you could
remove the tautological 'Als_' everywhere? Perhaps a root package of
'Audio' and a child package of 'Audio.ALS' - that way you could expand
to support other audio file formats 'Audio.mp3', 'Audio.Wav', etc.

Again a style thing, but '_T' looks rather ugly and isn't common usage
- see the RM, esp the Ada.Container.* hierarchy for naming ideas.

Cheers
-- Martin



^ permalink raw reply	[relevance 0%]

* Re: newbie problem
    2009-05-13 14:54  5% ` Martin
  2009-05-13 15:44  7% ` Ludovic Brenta
@ 2009-05-13 18:00  6% ` Olivier Scalbert
  2009-05-13 18:51  0%   ` Martin
  2009-05-14  2:59  5% ` anon
  3 siblings, 1 reply; 130+ results
From: Olivier Scalbert @ 2009-05-13 18:00 UTC (permalink / raw)


Finally I have done some changes. Als_Create is now a procedure.

Here is the code:

--------------------------------------
-- adasound.ads
--------------------------------------
private with Ada.Sequential_Io;

package adasound is

     type Amplitude_T is new Float;
     type Frequency_T is new Float;
     type Time_T      is new Float;

     type Stereo_Amplitude_T is record
         Left : Amplitude_T;
         Right: Amplitude_T;
     end record;

     type Als_File_T is limited private;

     procedure Als_Create(Als_File: out Als_File_T; File_Name: String);
     procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude: 
Stereo_Amplitude_T);
     procedure Als_Close(Als_File: out Als_File_T);

private
     package Stereo_Amplitude_Io is new Ada.Sequential_Io 
(Stereo_Amplitude_T);

     type Als_File_T is record
         File_Type: Stereo_Amplitude_Io.File_Type;
         -- perhaps more stuff later
     end record;

end adasound;

--------------------------------------
-- adasound.adb
--------------------------------------
package body adasound is

procedure Als_Create(Als_File: out Als_File_T; File_Name: String) is
     File: Stereo_Amplitude_Io.File_Type;
begin
     Stereo_Amplitude_Io.Create(Als_File.File_Type, 
Stereo_Amplitude_Io.Out_File, File_Name);
end Als_Create;

procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude: 
Stereo_Amplitude_T) is
begin
     Stereo_Amplitude_Io.Write(Als_File.File_Type, Stereo_Amplitude);
end Als_Write;

procedure Als_Close(Als_File: out Als_File_T) is
begin
     Stereo_Amplitude_Io.Close(Als_File.File_Type);
end Als_Close;

end adasound;

--------------------------------------
-- driver.adb
--------------------------------------
with adasound;
use adasound;

procedure driver is
     Als_File : Als_File_T;
     Stereo : Stereo_Amplitude_T;
     Sample_Rate : constant Integer := 44_100;
     Nb_Seconds  : constant Integer :=  3_600;
begin
     Stereo.Left  := 0.0;
     Stereo.Right := 0.0;
     Als_Create(Als_File, "test.als");
     for i in 1..Sample_Rate * Nb_Seconds loop
         Als_Write(Als_File, Stereo);
     end loop;
     Als_Close(Als_File);
end driver;

I do not know if the design is better or not but at least it works.

I am also very pleased with the performance. Of course, it is nearly 
only IO but ...

time ./driver
real    0m15.648s
user    0m10.305s
sys     0m3.364s

ls -l test.als
-rw-r--r-- 1 ols ols 1270080000 2009-05-13 18:41 test.als


Olivier.



^ permalink raw reply	[relevance 6%]

* Re: newbie problem
    2009-05-13 14:54  5% ` Martin
@ 2009-05-13 15:44  7% ` Ludovic Brenta
  2009-05-13 18:00  6% ` Olivier Scalbert
  2009-05-14  2:59  5% ` anon
  3 siblings, 0 replies; 130+ results
From: Ludovic Brenta @ 2009-05-13 15:44 UTC (permalink / raw)


Olivier Scalbert wrote on comp.lang.ada:
> Problem 1: it does not compile !
> adasound.ads:23:10: completion of nonlimited type cannot be limited
> adasound.ads:23:10: component "File_Type" of type "Als_File_T" has
> limited type

File_Type is of a limited type; any type containing it must therefore
also be limited.  Martin and Adam explained that very well.  My
preferred solution would be to make Als_File_T limited, too, since it
also represents a file.

> Problem 2: how to avoid the first "with Sequential_Io;" ?

Solution 1, as explaines by Martin: private with Ada.Sequential_IO;
this assumes that the presence of the with clause is only a minor
problem.  I would tend to agree that this problem is minor.

Solution 2: If you absolutely want to hide the with clause, you can
move it to the body of your package by making Als_File_T completely
opaque, like so:

package Adasound is
   type Als_File_T is private; -- or limited private
private
   type Internal_T;
   type Als_File_T is access Internal_T;
end Adasound;

with Ada.Sequential_IO;
package body Adasound is
   package Stereo_Amplitude_IO is new Sequential_Io
(Stereo_Amplitude_T);
   type Internal_T is limited record
      File_Type : Stereo_Amplitude_IO.File_Type;
   end record;
end Adasound;

The drawback of making Als_File_T opaque is that not even child
packages of Adasound can see the internals of the type.  This may be a
problem if you want to write unit tests (which are often child
packages or child procedures of the unit under test).

--
Ludovic Brenta.



^ permalink raw reply	[relevance 7%]

* Re: newbie problem
  2009-05-13 14:54  5% ` Martin
@ 2009-05-13 15:20  6%   ` Olivier Scalbert
  0 siblings, 0 replies; 130+ results
From: Olivier Scalbert @ 2009-05-13 15:20 UTC (permalink / raw)


Martin wrote:
>> Problem 1: it does not compile !
>> adasound.ads:23:10: completion of nonlimited type cannot be limited
>> adasound.ads:23:10: component "File_Type" of type "Als_File_T" has
>> limited type
> 
> Store an 'access' to the limited type.
> 
>> Problem 2: how to avoid the first "with Sequential_Io;" ?
> 
> private with Ada.Sequential_IO;  -- I always prefer the
>                                  -- Ada. prefix just to be clear
>                                  -- it's a standard unit to any
>                                  -- 'casual' reader
> 
> Cheers
> -- Martin

Thanks Martin,

I have modified the specification and it compiles now:

private with Ada.Sequential_Io;

package adasound is

     type Amplitude_T is new Float;
     type Frequency_T is new Float;
     type Time_T      is new Float;

     type Stereo_Amplitude_T is record
         Left : Amplitude_T;
         Right: Amplitude_T;
     end record;

     type Als_File_T is private;

     function  Als_Create(File_Name: String) return Als_File_T;
     procedure Als_Write(Als_File: Als_File_T; Stereo_Amplitude: 
Stereo_Amplitude_T);
     procedure Als_Close(Als_File: Als_File_T);

private
     package Stereo_Amplitude_Io is new Ada.Sequential_Io 
(Stereo_Amplitude_T);

     type Als_File_T is record
         File_Type: access Stereo_Amplitude_Io.File_Type;
         -- perhaps more stuff later
     end record;

end adasound;


How can implement the Als_Create function ?
Here is my code, but it does not compile !

package body adasound is

function Als_Create(File_Name: String) return Als_File_T is
     Result : Als_File_T;
     File: Stereo_Amplitude_Io.File_Type; -- Error !!!
begin
     Stereo_Amplitude_Io.Create(File, Stereo_Amplitude_Io.Out_File, 
File_Name);
     Result.File_Type := File; -- Line 10 Error !!!
     return Result;
end Als_Create;
...

gcc-4.3 -c adasound.adb
adasound.adb:10:22: left hand of assignment must not be limited type


Olivier.







^ permalink raw reply	[relevance 6%]

* Re: newbie problem
  @ 2009-05-13 14:54  5% ` Martin
  2009-05-13 15:20  6%   ` Olivier Scalbert
  2009-05-13 15:44  7% ` Ludovic Brenta
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 130+ results
From: Martin @ 2009-05-13 14:54 UTC (permalink / raw)


On May 13, 3:16 pm, Olivier Scalbert <olivier.scalb...@algosyn.com>
wrote:
> Problem 1: it does not compile !
> adasound.ads:23:10: completion of nonlimited type cannot be limited
> adasound.ads:23:10: component "File_Type" of type "Als_File_T" has
> limited type

Store an 'access' to the limited type.

> Problem 2: how to avoid the first "with Sequential_Io;" ?

private with Ada.Sequential_IO;  -- I always prefer the
                                 -- Ada. prefix just to be clear
                                 -- it's a standard unit to any
                                 -- 'casual' reader

Cheers
-- Martin



^ permalink raw reply	[relevance 5%]

* Re: How to exit an Ada program with (unix shell) error code?
  @ 2009-05-07  9:08  4%   ` anon
  0 siblings, 0 replies; 130+ results
From: anon @ 2009-05-07  9:08 UTC (permalink / raw)


There are basic three types of programs for computers.  

        The first, are the "Stand-Alone" programs aka OS types, which do not 
        return and have no needs for Ada.Command_Line routines.  In order 
        words, there are no links for the Ada.Command_Line package and the 
        Set_Exit_Status routine.

        The second type are "Device Drivers" or "System/Kernel" installable 
        "Modules".  And the Ada.Command_Line package is not legal. But the 
        Kernel requires the "Module" to notify the kernel by using the 
        "exit status" so that the kernel can know if it should reclaim the 
        memory, etc, on errors. Using a "function" type of module install 
        program is the only way a "Module" can be written and have an 
        "exit status".
 
        Note: Ada as a computer language should be allowed to create 
              these type of programs which means that Ada needs to 
              support main subprogram that are functions.

        The third is "Applications" programs but runs under a command shell, 
        which contains the links for the Ada.Command_Line package. Which 
        allow a program to use Ada.Command_Line.Set_Exit_Status routine. 
        But the RM does not force a programmer to use the Set_Exit_Status 
        in Ada.Command_Line package to return the "exit status"


Note: In GNAT, using a function for the main subprogram, the return value 
      of this function will be the "exit status". And if the program 
      uses the Ada.Command_Line.Set_Exit_Status routine the value is 
      discarded.


Then you have one of the "High Priority" concepts within the Ada language 
that is the "Safety and Security" concerns which make it illegal and against 
the RM for any Ada program to cause the OS or an external environment to 
become unstable. This includes, the execution of the Ada programs, or the 
result of its exiting. Now returning a "exit status" help keep the OS 
stable. Because the "exit status" can informs the OS if it needs to perform 
any error recovery processes on the resources used by the Ada program before 
reclaiming that resource, such as closing files that Ada can not close or 
reset devices that Ada has no knowledge of how to do.

        And since there are times where the Ada.Command_Line package is 
not available, there has to be a way to send a "exit status" to the OS 
in those case. The easiest is to use function type of "main subprograms" 
which returns the program "exit status".  One reason is if the Ada 
programmer, is using a "close source" Ada RTL there is no way of knowing 
how to perform a Set_Exit_Status for that version of Ada. 

Note: Is Ada becoming like C!!!! 

        Ada does allow some tricks that makes it more like C's nasty little 
tricks. Like using "pragma Import" and "pragma Export" within Ada to Ada 
packages which bypasses Ada package design structure is one. GNAT loves 
this one in the GNAT RTL. This also, can cause errors in the elaboration 
order which may result in other problems.

        Also, another one is in all of the GNAT programs (like gnatmake, 
gnatbind, gnatlink to name three) in the GNAT package are using a 
File_Descriptor type and direct to C type of IO routines which are defined 
in the System.OS_LIB or the older GNAT.OS_LIB package. These are not apart
of the RM.   Why did they not just use "File_Type" from either Ada.Text_IO, 
Ada.Direct_IO, or Ada.Sequential_IO standard Ada packages. All source files 
and the assembly translated output files can be handled by the Ada.Text_IO 
package. While the ALI files could use either Ada.Text_IO or 
Ada.Sequential_IO package. And as for the objects files, well in the 
GNAT design, all object files are created by the gcc "as", and are linked 
with either the gcc's "collect2" or "ld" be default. 

Note: There are options for other version of linkers, but GNATLINK 
defaufts to gcc's "collect2" or "ld". 

        Actually it seams that every year more and more trashy C routines 
and data types are inserted in the packages that GNAT wants programmers to 
use. Like the C file structure and routines in the System.OS_LIB package. 
Yes, some of those have been around for years, but by now Adacore should be
rewritting then to use pure RM Ada. And provide only a limited standard 
C and OS library routines, such as may be System.Sockets.  Plus, every year 
there are always additional C files, to be interfaces C libraries and OS to Ada. 
And I notice last year the GNAT GPL 2008 had one C file that replaced a 
couple of Ada routines that were in the GNAT GPL 2007. That's going away 
from Ada back to C, that's just WRONG!


In <356247f9-4a83-44aa-a412-4500e6af19cf@f1g2000prb.googlegroups.com>, Adam Beneschan <adam@irvine.com> writes:
>On May 5, 8:34 am, Jean-Pierre Rosen <ro...@adalog.fr> wrote:
>> Adam Beneschan a =E9crit :> Right; and even if your Ada compiler *does* s=
>upport functions that
>> > return integers as main programs, and you're compiling for some
>> > operating system with an "x" in its name (or Solaris), this does *not*
>> > mean that the Ada compiler will treat the function result as the
>> > status code.  The compiler could decide that the function result is
>> > something to be formatted and spit out onto standard output.  If an
>> > Ada implementation supports parameters and/or function results on main
>> > programs, the language leaves it up to the implementation how those
>> > are interpreted.  There's no rule that says that the interpretation
>> > has to mimic the behavior of the C language (thank God).  So anon's
>> > solution may work on GNAT, but it can't be assumed to work anywhere
>> > else.
>>
>> That's right from a legalistic point of view, but don't forget that
>> compiler writers are not masochists.
>
>That last statement might be tautologically false.  :) :) :)
>
>In any case, if you're implying that writing the extra code needed to
>get the program to display the function result on the standard output
>is an act of self-inflicted pain---trust me, it's nowhere near as
>painful as trying to understand and implement 3.10.2.
>
>
>> If an implementation supports
>> functions returning integers as main programs, I would be very surprised
>> if it was not interpreted as the return code, since this is what the
>> consumer would expect...
>
>Irvine Compiler's Ada compiler (the one I masochistically work on
>maintaining) does behave in the way I described.  Main subprograms can
>be procedures or functions; they can take parameters that are scalars
>or String (which are parsed from the command line); and they can be
>functions that return scalars or String, with the result being
>formatted and displayed on the standard output.  The compiler was
>originally written to run on Unix and VMS---and, by the way, I'm not
>sure that VMS supports the convention that a main program's function
>result becomes the return status (which is not a simple zero or non-
>zero as it is on Unix, if I recall correctly).  The compiler also runs
>on a variety of other targets, although the parameters and function
>result aren't supported in most cases.
>
>Surprised?  Well, the compiler is consistent across platforms and with
>respect to allowing various types to be used as function results.  It
>wouldn't make any sense to break consistency and make integer-
>returning functions on Unix-type platforms behave differently.  And
>nobody has ever complained about it.  As for whether it's what I'd
>expect if I were a consumer...  I'm not much of a C hack, but when I
>do use C I use exit() to set the status code, not "return", which
>seems to me to pervert the meaning of what a "function" and a function
>result should be; or as Georg said it, it's "playing tricks" with the
>language.  I don't feel any particular need to expect Ada compilers to
>support the same sort of trickery C programmers are used to.
>
>But that's just my opinion.
>
>                              -- Adam
>
>
>




^ permalink raw reply	[relevance 4%]

* Re: Load an object from a file
  @ 2009-04-09 20:32  4%   ` Olivier Scalbert
  0 siblings, 0 replies; 130+ results
From: Olivier Scalbert @ 2009-04-09 20:32 UTC (permalink / raw)


Hi,

I still have one question ...
How can I implement the Load_Class procedure that will use the Input 
function?
I do not know how to get the needed stream from a given file name.
And I do not know how to define the Class_File_Structure result (I get 
an unconstrained subtype (need initialization)).

Thanks,

Olivier




Here is my spec:
--------------------------

package jvm is

     type Byte_T is range 0..255;
     for Byte_T'Size use 8;

     type U2_T is range 0 .. 2 ** 16 - 1;
     type U4_T is range 0 .. 2 ** 32 - 1;

     type cp_info_T is new Integer; -- Just for test !

     type Constant_Pool_Array_T is array (U2_T range <>) of cp_info_T;

     type Class_File_Structure_T(
                                 constant_pool_count,
                                 interfaces_count,
                                 fields_count,
                                 methods_count,
                                 attributes_count : U2_T) is record

         Magic               : U4_T;
         Minor_Version       : U2_T;
         Major_Version       : U2_T;
         Constant_Pool : Constant_Pool_Array_T (2 .. constant_pool_count);
         --interfaces   : Interfaces_Array_T (1 .. interfaces_count);
     end record;

     procedure Run;

     procedure Load_Class(File_Name: String);

     function Input(Stream : not null access 
Ada.Streams.Root_Stream_Type'Class)
                    return Class_File_Structure_T; -- see RM 13.13(22) 
and following
     for Class_File_Structure_T'Input use Input; -- as per RM 13.13(38/2)

end jvm;


Here is the body:
--------------------------

with Ada.Text_IO;                          use Ada.Text_IO;
with Ada.Sequential_IO;
with Ada.Unchecked_Deallocation;

package body jvm is

     procedure run is
     begin
         Load_Class("Main.class");
     end run;


     procedure Load_Class(File_Name: String) is

         Class_File_Structure: Class_File_Structure_T; -- (unconstrained 
subtype (need initialization)
     begin
         Put_Line(File_Name);

         Class_file_Structure := Input(Stream ???);


     end Load_Class;

     function Input(Stream : not null access 
Ada.Streams.Root_Stream_Type'Class)
                    return Class_File_Structure_T is
         Magic               : U4_T;
         Minor_Version       : U2_T;
         Major_Version       : U2_T;
         Constant_Pool_Count : U2_T;
         type Constant_Pool_Array_Access is access Constant_Pool_Array_T;
         procedure Free is new Ada.Unchecked_Deallocation
           (Constant_Pool_Array_T, Constant_Pool_Array_Access);
         Constant_Pool : Constant_Pool_Array_Access;

     begin
         -- Read
         U4_T'Read(Stream, Magic);
         U2_T'Read(Stream, Minor_Version);
         U2_T'Read(Stream, Major_Version);
         U2_T'Read (Stream, Constant_Pool_Count);
         Constant_Pool := new Constant_Pool_Array_T (1 .. 
Constant_Pool_Count - 1);
         Constant_Pool_Array_T'Read (Stream, Constant_Pool.all);

         -- Fill in to the result
         declare
             Result : Class_File_Structure_T
               (constant_pool_count => Constant_Pool_Count,
                interfaces_count => 0, --Interfaces_Count,
                fields_count => 0, --Fields_Count,
                methods_count => 0, --Methods_Count,
                attributes_count => 0); --Attricutes_Count);
         begin
             Result.Magic := Magic;
             Result.Minor_Version := Minor_Version;
             Result.Major_Version := Major_Version;
             Result.Constant_Pool := Constant_Pool.all;
             Free(Constant_Pool);
             return Result;
         end;
     end;

end jvm;




Ludovic Brenta wrote:
> Olivier Scalbert wrote on comp.lang.ada:
>> Hello everybody !
>>
>> In my Ada self-study context, I was asking myself how can I create and
>> fill objects or records from a file.
>> As an example, I have tried to represent a java class file format
>> structure and fill it with a .class java file.
>>
>> The ClassFile structure is something like:
>>
>>      ClassFile {
>>         u4 magic;
>>         u2 minor_version;
>>         u2 major_version;
>>         u2 constant_pool_count;
>>         cp_info constant_pool[constant_pool_count-1];
>>         u2 access_flags;
>>         u2 this_class;
>>         u2 super_class;
>>         u2 interfaces_count;
>>         u2 interfaces[interfaces_count];
>>         u2 fields_count;
>>         field_info fields[fields_count];
>>         u2 methods_count;
>>         method_info methods[methods_count];
>>         u2 attributes_count;
>>         attribute_info attributes[attributes_count];
>>      }
>>
>> JVM Specs can be found there:http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc...
>>
>> I have no problem to represent and to fill from file, the first four fields.
>> But I do not know what is the best (Ada) way of representing the array
>> of info constant_pool as the size is only known at run time.(=
>> constant_pool_cout).
> 
> I would create a record type with one discriminant for each array,
> like so:
> 
> type Constant_Pool_Array is array (Positive range <>) of cp_info;
> type Interfaces_Array is array (Positive range <>) of u2;
> -- etc.
> 
> type Class_File
>   (constant_pool_count,
>    interfaces_count,
>    fields_count,
>    methods_count,
>    attributes_count : u2)
> is record
>    ...
>    constant_pool : Constant_Pool_Array (2 .. constant_pool_count);
>    ...
>    interfaces : Interfaces_Array (1 .. interfaces_count);
>    ... etc.
> end record;
> 
>> Also how can I fill this array ?
> 
> You would normally simply call the predefined Class_File'Read but this
> wouldn't work since the order of the components in type Class_File
> does not match the order in the file. So, you'd specify your own Read:
> 
> function Input(
>    Stream : not null access Ada.Streams.Root_Stream_Type'Class)
>    return Class_File); -- see RM 13.13(22) and following
> for Class_File'Input use Input; -- as per RM 13.13(38/2)
> 
> function Input(
>    Stream : not null access Ada.Streams.Root_Stream_Type'Class)
>    return Class_File)
> is
>    Constant_Pool_Count : u2;
>    type Constant_Pool_Array_Access is access Constant_Pool_Array;
>    procedure Free is new Ada.Unchecked_Deallocation
>      (Constant_Pool_Array, Constant_Pool_Array_Access);
>    Constant_Pool : Constant_Pool_Array_Access;
> begin
>    ...
>    u2'Read (Stream, Constant_Pool_Count);
>    Constant_Pool := new Constant_Pool_Array (1 .. Constant_Pool - 1);
>    Constant_Pool_Array'Read (Stream, Constant_Pool.all);
>    ...
> 
> After reading all members, construct the result:
> 
> declare
>    Result : Class_File
>   (constant_pool_count => Constant_Pool_Count,
>    interfaces_count => Interfaces_Count,
>    fields_count => Fields_Count,
>    methods_count => Methods_Count,
>    attributes_count => Attricutes_Count);
> begin
>    Result.Constant_Pool := Constant_Pool.all;
>    ...
>    Free (Constant_Pool);
>    ...
>    return Result;
> end;
> end Input;
> 
> You can also eliminate the use of access types and dynamic allocation
> and deallocation by nesting declare blocks, e.g.
> 
> u2'Read (Stream, Constant_Pool_Count);
> declare
>    Constant_Pool : Constant_Pool_Array (1 .. Constant_Pool_Count);
> begin
>    Constant_Pool_Array'Read (Stream, Constant_Pool);
>    ...
>    u2'Read (Stream, Interfaces_Count);
>    declare
>       Interfaces : Interfaces_Count_Array (1 .. Interfaces_Count);
>    begin
>       ...
>    end;
> end;
> 
> HTH
> 
> --
> Ludovic Brenta.



^ permalink raw reply	[relevance 4%]

* Re: C getchar() functionality in Ada
  2009-02-17  8:16  6%     ` Niklas Holsti
@ 2009-02-17 13:01  0%       ` Georg Bauhaus
  0 siblings, 0 replies; 130+ results
From: Georg Bauhaus @ 2009-02-17 13:01 UTC (permalink / raw)


Niklas Holsti schrieb:
> Thomas Locke wrote:
>> Jeffrey R. Carter wrote:
>>
>>> This is one of the latter cases. You should not be using Character,
>>> String, or Ada.Text_IO for this. I suggest you look at streams and
>>> Ada.Text_IO.Text_Streams.
> 
> Or Ada.Sequential_IO, instantiated for Character (or Storage_Element,
> etc.) which seems to me the best match to the original C program.
> However, Sequential_IO has the problem that the standard-input and
> standard-output channels are not accessible, you must Open named files.
> 
>> I will try this when my Ada skills have improved a bit. For now I will
>> focus on learning how to best use Text_IO.
>>
>> I wouldn't mind a smallish example on using Ada.Text_IO.Text_Streams
>> though...  :D
> 
> Here is a copy-input-to-output program with Text_Streams and Character:
> 
> with Ada.Text_IO.Text_Streams;
> 
> procedure Acopy
> is
>    use Ada.Text_IO;
>    use Ada.Text_IO.Text_Streams;
> 
>    Input  : constant Stream_Access := Stream (Standard_Input);
>    Output : constant Stream_Access := Stream (Standard_Output);
> 
>    Item : Character;
> 
> begin
> 
>    while not End_Of_File (Standard_Input) loop
> 
>       Character'Read (Input , Item);
>       Character'Write(Output, Item);
> 
>    end loop;
> 
> end Acopy;


We can write the same program in Ada, of course. :-)
Only, the Ada version is likely written without
resorting to the C's idiomatic
"statement-used-as-expression-in-the-loop-conditional".

with Interfaces.C;

procedure C_1 is

   use Interfaces.C;

   function getchar return int;
   function putchar(item: int) return int;

   pragma Import(C, getchar);
   pragma Import(C, putchar);

   EOF: constant int := -1;             --  see <stdio.h>
   c, not_checked: int;

begin
   loop
      c := getchar;
      exit when C = EOF;
      not_checked := putchar(c);
   end loop;
end C_1;



^ permalink raw reply	[relevance 0%]

* Re: C getchar() functionality in Ada
  @ 2009-02-17  8:16  6%     ` Niklas Holsti
  2009-02-17 13:01  0%       ` Georg Bauhaus
  0 siblings, 1 reply; 130+ results
From: Niklas Holsti @ 2009-02-17  8:16 UTC (permalink / raw)


Thomas Locke wrote:
> Jeffrey R. Carter wrote:
> 
>> This is one of the latter cases. You should not be using Character, 
>> String, or Ada.Text_IO for this. I suggest you look at streams and 
>> Ada.Text_IO.Text_Streams.

Or Ada.Sequential_IO, instantiated for Character (or 
Storage_Element, etc.) which seems to me the best match to the 
original C program. However, Sequential_IO has the problem that the 
standard-input and standard-output channels are not accessible, you 
must Open named files.

> I will try this when my Ada skills have improved a bit. For now I will 
> focus on learning how to best use Text_IO.
> 
> I wouldn't mind a smallish example on using Ada.Text_IO.Text_Streams 
> though...  :D

Here is a copy-input-to-output program with Text_Streams and Character:

with Ada.Text_IO.Text_Streams;

procedure Acopy
is
    use Ada.Text_IO;
    use Ada.Text_IO.Text_Streams;

    Input  : constant Stream_Access := Stream (Standard_Input);
    Output : constant Stream_Access := Stream (Standard_Output);

    Item : Character;

begin

    while not End_Of_File (Standard_Input) loop

       Character'Read (Input , Item);
       Character'Write(Output, Item);

    end loop;

end Acopy;


-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



^ permalink raw reply	[relevance 6%]

* Re: Ada.Directories problems, a summary
  @ 2009-01-01 20:41  3% ` anon
  0 siblings, 0 replies; 130+ results
From: anon @ 2009-01-01 20:41 UTC (permalink / raw)



    1. OS problem. Name encoding must match OS and file system that being 
       used. And that may be different between locations or OSs.

    2. OS problem, that all programming languages have to deal with.

    3. No need. The usage is just as easy as using a Alphanumeric 
       directory names. And traversing the directory tree is more portable
       since more current file system use "." and "..". It is also, easy
       to check and skip them while going deeper within a directory tree.
       Note, most file search routines understand how to deal with these 
       two special directories.

    4. Another standards OS problem. Drives are not directories in Windows 
       and DOS. And this includes some embedded OS. Actually most Windows 
       uses wish that MS would replace the DOS drive letters with "/" 
       directory structure because of the internet usage of "/".

    5. Windows and it's apps designs loves Popups. This is a MS problem 
       not Ada or GNAT.

    6. Another OS problem. If a drive is not ready, is it a "drive not mounted"
       or is there a problem with the drive such as a "drive crash".  So, this 
       not useful, in Ada.Directories or any file type package ( Ada.Direct_IO, 
       Ada.Sequential_IO, or Ada.Text_IO ). The drive should be installed and 
       mounted before Ada even tries to access any file or directory routine. 

       Since, most current computers system have CD/DVD and USB ports 
       that allow Flash or external drives. Ada needs an Ada.OS_Library for 
       common and standard routines that can handle mounting or hardware
       problems. In this package, the program could ask if a drive is 
       mounted or is the drive working proper.  Or the program could 
       request for a drive aka CD/DVD to be inserted. Of course this would 
       mean another Windows popup screen.

    7. Not a standard concept in all file systems or OSs and may be phase out
       completely. For some OS, its a security option (allowing duplicate files 
       for simple file backup concept, etc), that should be handled by an 
       Security package. For Windows, the version numbers are used as one 
       way to allow floppies to use long file names under the MS FAT files 
       structure.  But as flash drives (using FS which uses long file names 
       structure) replace floppies so it seams that MS will phase out the use 
       of the version numbers design. Maybe VMS should too.

       So, the only thing that you have stated that may alter Ada is the one 
that causes an Ada.OS_library package. To determine rather a drive is 
mounted or has crashed. And another routine to mount a drive.


In <17rohiaha9ome$.1gz45no0bqro2.dlg@40tude.net>, "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>After experimenting with Ada.Directories I collected the issues I think
>must be addressed to make Ada.Directories more usable:
>
>1. Name encoding. Either String versions should be UTF-8 or else replaced
>with Wide_Wide_String ones.
>
>2. Name canonization / comparison functions. Presently it is impossible to
>compare files by names because the same file may have potentially an
>infinite number of names.
>
>3. Fake children "." and ".." should have special File_Kind
>(Virtual_Directory_File, for example). Else it is impossible to traverse
>the directory tree in a portable way.
>
>4. There should be a variant of Start_Search without the Directory
>parameter, in order to enumerate the roots of the file systems. For
>example, to find drive letters under Windows, network shares, mount points
>etc.
>
>5. The behavior of Exists must be specified for the case of mountable
>volumes. Presently GNAT implementation pops a message box under Windows.
>This should be outlawed.
>
>6. Is_Mountable / Is_Removable functions should be provided.
>
>7. Version number in addition to Containing_Directory, Base_Name and
>Extension. (Files have version numbers under VMS)
>
>Any comments?
>
>P.S. Happy New Year!
>
>-- 
>Regards,
>Dmitry A. Kazakov
>http://www.dmitry-kazakov.de




^ permalink raw reply	[relevance 3%]

* Re: File "form" and mainstream systems.
  2008-08-18 13:40  5% File "form" and mainstream systems Maciej Sobczak
@ 2008-08-22  4:00  0% ` Randy Brukardt
  0 siblings, 0 replies; 130+ results
From: Randy Brukardt @ 2008-08-22  4:00 UTC (permalink / raw)


Sure, but it's implementation-defined, and thus may vary from compiler to 
compiler. Can't do anything portable with it.

Janus/Ada uses Form to control the file sharing mode on Windows, and also to 
set (or not) the CP/M compatibility mode (where <ctrl>-Z is treated as a 
file terminator). I'm pretty sure GNAT has such capabilities, too, but I 
think the syntax is different. (Remember that Form is a String).

                                     Randy.

"Maciej Sobczak" <see.my.homepage@gmail.com> wrote in message 
news:6f4661c3-0b11-4b2e-a258-40b7749dce97@y21g2000hsf.googlegroups.com...
> Hi,
>
> There is a Form parameter in file creation/open procedures (for
> example Ada.Sequential_IO.Create).
> The corresponding function allows to retrieve the "form" for the file
> object that is already open.
>
> Is there any use for the file "form" on POSIX or Windows?
>
> --
> Maciej Sobczak * www.msobczak.com * www.inspirel.com
>
> Database Access Library for Ada: www.inspirel.com/soci-ada 





^ permalink raw reply	[relevance 0%]

* File "form" and mainstream systems.
@ 2008-08-18 13:40  5% Maciej Sobczak
  2008-08-22  4:00  0% ` Randy Brukardt
  0 siblings, 1 reply; 130+ results
From: Maciej Sobczak @ 2008-08-18 13:40 UTC (permalink / raw)


Hi,

There is a Form parameter in file creation/open procedures (for
example Ada.Sequential_IO.Create).
The corresponding function allows to retrieve the "form" for the file
object that is already open.

Is there any use for the file "form" on POSIX or Windows?

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



^ permalink raw reply	[relevance 5%]

* Re: Files and controlled types
  2008-03-09 13:27  0%   ` Maciej Sobczak
@ 2008-03-10 15:37  0%     ` Adam Beneschan
  0 siblings, 0 replies; 130+ results
From: Adam Beneschan @ 2008-03-10 15:37 UTC (permalink / raw)


On Mar 9, 6:27 am, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> On 9 Mar, 04:12, "Jeffrey R. Carter" <spam.jrcarter....@spam.acm.org>
> wrote:
>
> > > File types are not Controlled.
> > > What is the rationale for this?
>
> > What makes you think they're not controlled.
>
> a) AARM
> b) trivial test
>
> > The ARM only gives the public view,
> > which is limited private; there's nothing to prevent the full view from being
> > controlled.
>
> There is nothing that mandates it and therefore I have to assume it is
> not done. This is actually what I see in tests.
>
> > In addition, the descriptions of Ada.Sequential_IO, Ada.Direct_IO,
> > and Ada.Text_IO all include the language "The type File_Type needs finalization
> > (see 7.6)".
>
> This is very good - I haven't notice it.
> It is very good, because then instead of broken library definition we
> can talk about implementation bugs - these are easier to fix.
>
> My little test follows:
>
> with Ada.Text_IO;
> procedure A is
>
>    procedure New_File (I : in Integer) is
>       Name : String := "temp/" & Integer'Image (I) & ".txt";
>       F : Ada.Text_IO.File_Type;
>    begin
>       Ada.Text_IO.Put_Line ("Opening " & Name);
>       Ada.Text_IO.Create (F, Ada.Text_IO.Out_File, Name);
> --      Ada.Text_IO.Close (F);
>    end New_File;
>
> begin
>    for I in -1000 .. -1 loop
>       New_File (I);
>    end loop;
> end;
>
> This program creates 1000 files with names "temp/-1000.txt",
> "temp/-999.txt", etc. (I use negative counters because I don't want to
> waste my time with that useless space in front of the image of
> positive integer value).
> If the File_Type has finalization, then this program is expected to
> finish correctly without the Close call (uncommented above).
> On my computer it fails with USE_ERROR after creating 253 files. If we
> add the three standard I/O streams, we get a reasonable assumption
> that the program has hit an implementation limit (256?) of open file
> descriptors.
> If I uncomment the Close call, the program properly creates full 1000
> set of files.
> I expect Close to be called automatically as part of finalization.

I'm not so sure.  What happens here?

    procedure New_File (I : in Integer) is
       Name : String := "temp/" & Integer'Image (I) & ".txt";
       F : Ada.Text_IO.File_Type;
    begin
       Ada.Text_IO.Put_Line ("Opening " & Name);
       Ada.Text_IO.Create (F, Ada.Text_IO.Out_File, Name);
       Ada.Text_IO.Set_Output (F);
    end New_File;

    procedure Proc is
    begin
       New_File (-17);
       Ada.Text_IO.Put_Line ("This is written to default output");
    end Proc;

New_File will set the current default output file to File.  When Proc
calls Put_Line, will it then write to that default output file, or
will Put_Line raise an exception or be erroneous?  I'm not 100% clear
on this.  Another question is, what do we (as language designers)
*want* it to do, or what should it do?

But in any case, I haven't seen anywhere in the RM that says that
finalizing a File_Type object involves closing it.  And examples like
this, involving default files or File_Access, show that perhaps you
don't *want* files to be closed when File_Type objects are finalized.
(The RM phrase that says a File_Type "needs finalization" is, I'm
afraid, a smokescreen; this clause has *no* impact whatsoever unless
you have a "pragma Restrictions(No_Nested_Finalization)" in effect,
which would make it illegal to declare certain File_Type objects.  See
AI95-360, http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00360.TXT?rev=1.11
.
This clause doesn't have any effect on the semantics.)

The bottom line is that things just aren't so simple, and it's not
obvious whether a File_Type "should" cause a Close when the File_Type
is finalized.

                               -- Adam



^ permalink raw reply	[relevance 0%]

* Re: Files and controlled types
  2008-03-09  3:12  5% ` Jeffrey R. Carter
  2008-03-09 13:27  0%   ` Maciej Sobczak
@ 2008-03-09 16:39  0%   ` gpriv
  1 sibling, 0 replies; 130+ results
From: gpriv @ 2008-03-09 16:39 UTC (permalink / raw)


On Mar 8, 11:12 pm, "Jeffrey R. Carter"
<spam.jrcarter....@spam.acm.org> wrote:
> Maciej Sobczak wrote:
>
> > File types are not Controlled.
> > What is the rationale for this?
>
> What makes you think they're not controlled. The ARM only gives the public view,
> which is limited private; there's nothing to prevent the full view from being
> controlled. In addition, the descriptions of Ada.Sequential_IO, Ada.Direct_IO,
> and Ada.Text_IO all include the language "The type File_Type needs finalization
> (see 7.6)".

Doesn't it mean that it's user responsibility to close the file?

George

>
> --
> Jeff Carter
> "No one is to stone anyone until I blow this whistle,
> do you understand? Even--and I want to make this
> absolutely clear--even if they do say, 'Jehovah.'"
> Monty Python's Life of Brian
> 74




^ permalink raw reply	[relevance 0%]

* Re: Files and controlled types
  2008-03-09  3:12  5% ` Jeffrey R. Carter
@ 2008-03-09 13:27  0%   ` Maciej Sobczak
  2008-03-10 15:37  0%     ` Adam Beneschan
  2008-03-09 16:39  0%   ` gpriv
  1 sibling, 1 reply; 130+ results
From: Maciej Sobczak @ 2008-03-09 13:27 UTC (permalink / raw)


On 9 Mar, 04:12, "Jeffrey R. Carter" <spam.jrcarter....@spam.acm.org>
wrote:

> > File types are not Controlled.
> > What is the rationale for this?
>
> What makes you think they're not controlled.

a) AARM
b) trivial test

> The ARM only gives the public view,
> which is limited private; there's nothing to prevent the full view from being
> controlled.

There is nothing that mandates it and therefore I have to assume it is
not done. This is actually what I see in tests.

> In addition, the descriptions of Ada.Sequential_IO, Ada.Direct_IO,
> and Ada.Text_IO all include the language "The type File_Type needs finalization
> (see 7.6)".

This is very good - I haven't notice it.
It is very good, because then instead of broken library definition we
can talk about implementation bugs - these are easier to fix.

My little test follows:

with Ada.Text_IO;
procedure A is

   procedure New_File (I : in Integer) is
      Name : String := "temp/" & Integer'Image (I) & ".txt";
      F : Ada.Text_IO.File_Type;
   begin
      Ada.Text_IO.Put_Line ("Opening " & Name);
      Ada.Text_IO.Create (F, Ada.Text_IO.Out_File, Name);
--      Ada.Text_IO.Close (F);
   end New_File;

begin
   for I in -1000 .. -1 loop
      New_File (I);
   end loop;
end;

This program creates 1000 files with names "temp/-1000.txt",
"temp/-999.txt", etc. (I use negative counters because I don't want to
waste my time with that useless space in front of the image of
positive integer value).
If the File_Type has finalization, then this program is expected to
finish correctly without the Close call (uncommented above).
On my computer it fails with USE_ERROR after creating 253 files. If we
add the three standard I/O streams, we get a reasonable assumption
that the program has hit an implementation limit (256?) of open file
descriptors.
If I uncomment the Close call, the program properly creates full 1000
set of files.
I expect Close to be called automatically as part of finalization.

So - is it the implementation (GNAT) bug?

Or maybe the finalization is concerned with memory management only
(buffers, etc.) and not with external resources? In that case I
consider it a bug in AARM.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



^ permalink raw reply	[relevance 0%]

* Re: Files and controlled types
  @ 2008-03-09  3:12  5% ` Jeffrey R. Carter
  2008-03-09 13:27  0%   ` Maciej Sobczak
  2008-03-09 16:39  0%   ` gpriv
  0 siblings, 2 replies; 130+ results
From: Jeffrey R. Carter @ 2008-03-09  3:12 UTC (permalink / raw)


Maciej Sobczak wrote:
> 
> File types are not Controlled.
> What is the rationale for this?

What makes you think they're not controlled. The ARM only gives the public view, 
which is limited private; there's nothing to prevent the full view from being 
controlled. In addition, the descriptions of Ada.Sequential_IO, Ada.Direct_IO, 
and Ada.Text_IO all include the language "The type File_Type needs finalization 
(see 7.6)".

-- 
Jeff Carter
"No one is to stone anyone until I blow this whistle,
do you understand? Even--and I want to make this
absolutely clear--even if they do say, 'Jehovah.'"
Monty Python's Life of Brian
74



^ permalink raw reply	[relevance 5%]

* Design help
@ 2007-03-13  0:50  7% Carroll, Andrew
  0 siblings, 0 replies; 130+ results
From: Carroll, Andrew @ 2007-03-13  0:50 UTC (permalink / raw)
  To: comp.lang.ada

I hope to have the database records be variable length however it may
make my life easier if they are fixed length due to the fact that some
of the record structures contain pointers.  I guess that would be access
type instead of pointer, anyway...

Here are the record structures I have defined:

   type attribute is tagged
      record
         name         : string_ptr;
         domain       : string_ptr;
         isprimarykey : boolean    := false;
         byte_start : integer;
         byte_end   : integer;
         size       : integer;
      end record;

   -----------------------------------
   --    Extended Attribute Types   --
   -----------------------------------
   type booleanattribute is new attribute with
      record
         value      : boolean := false;
      end record;
   type booleanattribute_ptr is access all booleanattribute'class;



   type integerattribute is new attribute with
      record
         value      : integer := 0;
      end record;
   type integerattribute_ptr is access all integerattribute'class;



   type stringattribute is new attribute with
      record
         value      : string_ptr;
      end record;
   type stringattribute_ptr is access all stringattribute'class;



   type dateattribute is new attribute with
      record
         year       : ada.calendar.year_number;
         month      : ada.calendar.month_number;
         day        : ada.calendar.day_number;
         value      : ada.calendar.time;
      end record;
   type dateattribute_ptr is access all dateattribute'class;



Obviously a database tuple could have any combination of these in it but
luckily I only have to worry about 5 attributes in a database table
schema.  So, I want to read a whole database tuple in as a bit string
(or something like that) and then be able to convert small sections of
it into the appropriate record structures above for each of the
attributes defined on the table.  

I can get rid of the string_ptr and set a default string size.  If I did
that I would be pretty close to a fixed-width database record and could
use something like Ludovic mentioned.  I think the drawback to this is
that I would have to have an I/O package for each type of attribute
right?  Like this:

package Attribute_IO is new Ada.Sequential_IO (Element_Type =>
Attribute); 
package BooleanAttribute_IO is new Ada.Sequential_IO (Element_Type =>
BooleanAttribute); 
package IntegerAttribute_IO is new Ada.Sequential_IO (Element_Type =>
IntegerAttribute); 
package StringAttribute_IO is new Ada.Sequential_IO (Element_Type =>
StringAttribute); 
package DateAttribute_IO is new Ada.Sequential_IO (Element_Type =>
DateAttribute); 

It seems like the second method that Ludovic mentioned might be better
in my case even if there is a fixed-width database record.  For each
type I have I could define a constructor function.  Like this:

function To_BooleanAttribute (Raw_Bytes : in
Ada.Streams.Stream_Element_Array)  return T
Is
Begin
	--but I don't know what to do here.
	--I'm assuming that because it's an array of stream_elements
(bytes?) 
      --that I can grab any number of them from the array.
	--something like Raw_Bytes(offset_byte..size);
      --where offset_byte index could be calculated ???
	--and the size would be taken from the size of the attribute
type.
      --
      --this is where I need help. 
   	--even if I knew that I could do the above, I wouldn't know how
to make
	--it officially a BooleanAttribute (in this case).  Would I use
a 
	--Qualified expression like:  return
BooleanAttribute'(Raw_Bytes(offset_byte..size));
End to_t;


HTHYHM



Andrew Carroll
Software Services
405-744-4943
andrew.carroll@okstate.edu



^ permalink raw reply	[relevance 7%]

* Re: Design help
  @ 2007-03-10 13:38  6% ` Ludovic Brenta
  0 siblings, 0 replies; 130+ results
From: Ludovic Brenta @ 2007-03-10 13:38 UTC (permalink / raw)


Andrew Carrol writes:
> I am trying to design (what I guess is) a database table adapter.  Yes,
> it is a master's course assignment.  The current design is to use a file
> and have one record per line.  My goal is to get each line to be
> "serialized" so I can read the whole line in bytes and then take chunks
> of it and "cast" those into objects.

The answer depends on whether or not your file contains fixed-width
records.  If that is the case, I would simply declare a record type
and use Sequential_IO for the record type directly, like e.g.

type Seconds_Since_Epoch is new Ada.Interfaces.Unsigned_32;

type DB_Record is record
   Primary_Key   : Ada.Interfaces.Unsigned_32;
   Name          : String (1 .. 20);
   Address       : String (1 .. 100);
   Date_Of_Birth : Seconds_Since_Epoch;
end record;

package DB_Record_IO is
   new Ada.Sequential_IO (Element_Type => DB_Record);

But if, on the other hand, the file contains variable-width records,
such as comma-separated values (CSV), you will need more sophisticated
conversion functions.  In that case, I would use Ada.Streams.Stream_IO
directly and convert the Stream_Elements one by one.

If you want to convert to objects of tagged types, you should provide
a constructor function for your tagged type, like so:

type T is tagged record ... end record;

function To_T (Raw_Bytes : in Ada.Streams.Stream_Element_Array)
   return T;

HTH

Note that the database file will probably not contain the tag itself.
OTOH, if it does, then you can just use streams.

-- 
Ludovic Brenta.



^ permalink raw reply	[relevance 6%]

* Re: typed pipes
  2007-02-24 20:17  5%                 ` Jacob Sparre Andersen
@ 2007-02-25  1:11  0%                   ` Björn Persson
  0 siblings, 0 replies; 130+ results
From: Björn Persson @ 2007-02-25  1:11 UTC (permalink / raw)


Jacob Sparre Andersen wrote:

> The first time I discussed it my suggestion was to use MIME types.  I
> am not sure that is the correct solution, but it should definitely be
> on a higher level than just Ada.Sequential_IO (Character).  Do we have
> something better than MIME types to give a short, but reasonably
> consistent description of a data stream?

Yes, MIME types seems a lot better than trying to describe complex data
types in detail. A MIME type is just a name for the file type, not a
description, but that's enough. If the program can handle the file type
then it already knows the structure and doesn't need a description, and if
it's an unknown file type then the program won't know what to do with the
file no matter how detailed the structure is described.

MIME types can be stored as extended attributes in some file systems. I
don't really know how feasible it would be to add them to pipes.

-- 
Bj�rn Persson                              PGP key A88682FD
                   omb jor ers @sv ge.
                   r o.b n.p son eri nu



^ permalink raw reply	[relevance 0%]

* Re: typed pipes
  @ 2007-02-24 20:17  5%                 ` Jacob Sparre Andersen
  2007-02-25  1:11  0%                   ` Björn Persson
  0 siblings, 1 reply; 130+ results
From: Jacob Sparre Andersen @ 2007-02-24 20:17 UTC (permalink / raw)


Bj�rn Persson wrote:

> No, it definitely couldn't be done in a Unix shell. It would require
> very deep changes to how the kernel handles files, including changes
> to the system calls. And if you had it for pipes you'd want it for
> disk files too, which would affect the filesystems. I suspect that
> the resulting operating system would be almost, but not quite,
> entirely unlike Unix.

;-)

> And how could you make it work for all programming languages?

The first time I discussed it my suggestion was to use MIME types.  I
am not sure that is the correct solution, but it should definitely be
on a higher level than just Ada.Sequential_IO (Character).  Do we have
something better than MIME types to give a short, but reasonably
consistent description of a data stream?

Greetings,

Jacob
-- 
"This page inadvertently left blank."



^ permalink raw reply	[relevance 5%]

* Re: Reading Float Data from a binary file into ada
  @ 2007-01-30 19:31  6% ` Niklas Holsti
  0 siblings, 0 replies; 130+ results
From: Niklas Holsti @ 2007-01-30 19:31 UTC (permalink / raw)


frikk wrote:
> Hello everyone! I am having a problem that I would love some help 
> with.
> 
> Essentially I was given a Visual Basic program that dumps a binary 
> configuration file with all of the variables in a set.  The variables 
> are each 32 bit floats, with the first 16 bits being the integer part 
> and the second 16 bits being a representation of the fraction (I'm not 
> sure if this is stanard - but its just how VB dumps the data). The 
> binary dump is basically a copy of the way VB stores the data in 
> memory.  I need to be able to use this data in ada.  There is a C 
> counterpart to this that makes use of a 'union' to grab the data 1 
> byte (8 bits) at a time, put them into a char array of size 4, then 
> use a 32 bit float to reference the data.  Is there somehow I can do 
> this in ada as well?

If that approach works in C, the same approach should work in Ada, as 
follows:

- Read the file with Ada.Sequential_IO (instantiated for
   Interfaces.Unsigned_8) or with Ada.Streams.Stream_IO.
   If you haven't used Streams before, Sequential_IO may
   be easier to start with.

- Use the functions Shift_Left or Shift_Right together with
   the "or" operator (all from Interfaces) to assemble 4 octets
   (Unsigned_8 values) into one 32-bit value of type
   Interfaces.Unsigned_32. You may have to experiment to
   get the octets in the right order.

- Then use Unchecked_Conversion to go from Unsigned_32 to Float.

The portability of this approach is the same as for the C code: it 
depends on the byte order in the VB file, the order in which you 
concatenate the 4 octets into a 32-bit value, and the representation of 
Float values. But if it works in C, it should work in Ada, assuming that 
the Ada Float type has the same representation as the C float type, 
which is likely.

Hope this helps...

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



^ permalink raw reply	[relevance 6%]

* Re: Advice on low level file handling.
  2006-04-02  2:47  4% Advice on low level file handling Peter C. Chapin
@ 2006-04-04  1:31  0% ` Randy Brukardt
  0 siblings, 0 replies; 130+ results
From: Randy Brukardt @ 2006-04-04  1:31 UTC (permalink / raw)


"Peter C. Chapin" <pchapin@sover.net> wrote in message
news:Xns9798DDB851DB4pchapinsovernet@198.186.192.137...
>
> I'm working on a program that needs to read an input file on a byte by
byte
> basis and examine bit fields and do bitwise shifting in some of these
> bytes. Other parts of the file are to be treated as uninterpreted data
> (this is an OpenPGP message file). Right now I'm using
Interfaces.Unsigned_
> 8 as the type to hold a single byte from the file and I'm instantiating
> Ada.Sequential_IO with this type to get the necessary file reading
> subprograms. So far this seems okay, but I'm wondering if this is the most
> appropriate way to do this.

Why aren't you using Stream_IO for this? You don't need to declare your own
types for this sort of I/O. Perhaps you thought that you could only use
Stream_IO with the stream attributes? Actually, I think it is more useful to
use by itself, especially in the sort of case you have here. Byte at a time
I/O can be painfully slow; Stream_IO lets you input a batch of stuff and
then process it.

>...Is that portable? I'm not extremely worried about
> portability, but I'd rather not sacrifice it for no reason.

A machine might not have Unsigned_8 (like the U2200, it has Unsigned_9
instead); but there is going to be a definition of Stream_Element. On the
vast majority of machines, that will be an 8-bit entity.

OTOH, if you *must* have an 8-bit byte, then I'd suggest declaring it
yourself and using Sequential_IO as you did.

> I can define a 64 bit modular type and that seems to work
> fine on gnat. Is that portable?

Not really, but an Ada compiler will reject the program if it doesn't work.
(As someone else pointed out, many Ada compilers don't support 64-bit
numbers.) But it's probably portable enough for your purposes; there isn't
much point in working around the lack of 64-bit math until you actually have
to work on a compiler that doesn't support it.

                                     Randy.





^ permalink raw reply	[relevance 0%]

* Advice on low level file handling.
@ 2006-04-02  2:47  4% Peter C. Chapin
  2006-04-04  1:31  0% ` Randy Brukardt
  0 siblings, 1 reply; 130+ results
From: Peter C. Chapin @ 2006-04-02  2:47 UTC (permalink / raw)



I'm working on a program that needs to read an input file on a byte by byte 
basis and examine bit fields and do bitwise shifting in some of these 
bytes. Other parts of the file are to be treated as uninterpreted data 
(this is an OpenPGP message file). Right now I'm using Interfaces.Unsigned_
8 as the type to hold a single byte from the file and I'm instantiating 
Ada.Sequential_IO with this type to get the necessary file reading 
subprograms. So far this seems okay, but I'm wondering if this is the most 
appropriate way to do this. Am I abusing package Interfaces? Should I be 
defining my own modular type or should I be using representation clauses 
with custom record types?

Also I need to count the number of bytes I process and the quantity may 
exceed 2**32. I can define a 64 bit modular type and that seems to work 
fine on gnat. Is that portable? I'm not extremely worried about 
portability, but I'd rather not sacrifice it for no reason.

Thanks for any advice you can offer.

Peter



^ permalink raw reply	[relevance 4%]

* Re: File
  2005-09-01 21:43  5% ` File Martin Dowie
@ 2005-09-02 15:39  0%   ` Martin Krischik
  0 siblings, 0 replies; 130+ results
From: Martin Krischik @ 2005-09-02 15:39 UTC (permalink / raw)


Martin Dowie wrote:

>> How I can open a sequential file and read char to char?
> 
> You could have a look at RM A.8 Ada.Sequential_IO.

If he only want to read characters then Direct_IO or Sequential_IO will do
just as needly.

He should really read:

http://en.wikibooks.org/wiki/Ada_Programming/Input_Output

and then make an informed decision based on what the rest of the program
should archive with the data read.

Martin

-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



^ permalink raw reply	[relevance 0%]

* Re: File
  @ 2005-09-01 21:43  5% ` Martin Dowie
  2005-09-02 15:39  0%   ` File Martin Krischik
  0 siblings, 1 reply; 130+ results
From: Martin Dowie @ 2005-09-01 21:43 UTC (permalink / raw)


TC wrote:
> How I can open a sequential file and read char to char?

You could have a look at RM A.8 Ada.Sequential_IO.



^ permalink raw reply	[relevance 5%]

* Re: Data table text I/O package?
  @ 2005-06-30 18:43  3%               ` Jacob Sparre Andersen
  0 siblings, 0 replies; 130+ results
From: Jacob Sparre Andersen @ 2005-06-30 18:43 UTC (permalink / raw)


Randy Brukardt wrote:
> "Jacob Sparre Andersen" <sparre@nbi.dk> wrote in message
> news:m2k6ku8w2s.fsf@hugin.crs4.it...
> > Randy Brukardt wrote:
> >
> > > I may be dense, but isn't this the purpose of XML? If so, why
> > > reinvent the wheel?
> >
> > The purpose of XML is to be _the_ universal file format.
> >
> >  a) I don't want a universal file format.
> >
> >  b) I don't believe in a universal file format.
> >
> >  c) XML is (almost) less readable than a binary file my purposes.
> >
> >  d) I'm _not_ going to switch away from tabulator separated tables
> >     for purposes, where tabulator separated tables are a sensible
> >     representation of the data in textual form.
> >
> > > (I personally think XML is way overused, more because it *can*
> > > be used than that it is worthwhile for the application. But this
> > > seems to be exactly the application that it was designed
> > > for. You'll end up with something like XML eventually anyway,
> > > why not start with it?)
> >
> > I'm afraid you completely misunderstood my problem.  It is not a
> > matter of a selecting a file format.  It is the matter of
> > automagically generating code for reading and writing that file
> > format.
> 
> Not at all. We like to say around here that you need to describe
> what your needs are, because often the program you are trying to
> write isn't appropriate for Ada. We usually use that for people
> trying to write C in Ada, but it should apply to everyone. :-)

I thought I had specified my needs.  But in case I forgot:

 a) A format for storing experimental data in tabular form.

 b) A format I easily can manipulate with my standard Unix toolbox.

 c) A format I easily can read and get an overview of (sections of)
    the data.

 d) A format that easily can be imported into programs I'm not in
    control of.  (concrete examples are Gnuplot, R, OOo Calc and
    Excel)

 e) A format I easily can read and write from my own programs.

Tabulator separated text files handle this quite fine (although OOo
and Excel users have to be careful about their number format settings
when they import the files).

> For program-to-program communication, there really are only two
> sensible options. If both ends are under your control, then using a
> binary format (with versioning and error detection if needed) is
> preferable, because it has the least overhead and there is no need
> for data conversion.

Yes.  But this doesn't handle b), c) and d).

> OTOH, if the performance of the connection isn't critical, then
> using a well-known standard format that already has needed tools for
> it seems like the best option. Even if you don't currently need to
> allow access by other systems, you're leaving the door open for
> future programs outside your system to use the data.

And which formats, besides tabulator separated text files, handle the
requirements?  XML doesn't handle b), c), d) and e).

> The cases that are neither of these and thus would make sense to use
> some internal, non-portable text format are essentially
> non-existent.

I think I have one of these "essentially non-existent" cases.  And
almost everything I do seems to be one of those cases.

> Note that human readability of program-to-program data is a
> non-issue.

You're apparently working in a very different area than I am.  Almost
all data going from one program to another should also be available in
a human-readable format.  My work is to look at data, not to program.
The programs are just written to process the data from one form into
another form - which hopefully can teach us something new and
interesting.

> Indeed, it is a mistake to try to bring that into the equation, as
> it adds a huge amount of overhead to the task. I've always used
> agile methods for debugging such data: if, in fact, I need to
> examine such a data stream, I'm write a program to display it. But I
> don't worry about that until/unless the need arises.

It seems that you're a programmer and not a researcher.  I am (almost)
always interested in the data.  I have yet to run into a case where I
wasn't interested in seeing the output of a program.

> It often does not arise, and even when it does, it's often not
> necessary to be able to display everything -- and it's often better
> to write a monitor for an interesting condition than filling a disk
> with 10 GB of text!

I would spend all my time writing monitors that way.

> So, all in all, I think you're trying to solve the wrong problem
> (finding a way to write a specific file format), rather than using
> an appropriate file format for Ada programs (usually binary).

It may be a long-time bad habit to use tabulator separated text files
for (intermediate) analysis results from experiments, but I haven't
found a convincing argument yet. -- If I could auto-generate the
monitor and the conversion programs to the programs I interact with,
then I might be convinced, but I would still have to hack some type
checking on top of Ada.Sequential_IO.  And the program for
auto-generating the export to Gnuplot would practically be identical
to the one I asked for initially anyway.

> But, as a friend of mine likes to say, "do what you want, because
> you will anyway!". :-)

A clever friend. :-)

Jacob
-- 
"Hungh. You see! More bear. Yellow snow is always dead give-away."



^ permalink raw reply	[relevance 3%]

* Re: Advanced file manipulation (multiple question)
  2005-03-01  9:30  5% Advanced file manipulation (multiple question) Steph-ADA
                   ` (2 preceding siblings ...)
  2005-03-01 17:49  0% ` Jeffrey Carter
@ 2005-03-02  2:42  0% ` Steve
  3 siblings, 0 replies; 130+ results
From: Steve @ 2005-03-02  2:42 UTC (permalink / raw)


Two solutions come to mind:
  1) Make a call to the underlying OS to copy the file.

  2) Use Ada.Direct_IO.

If you use Ada.Direct_Io, there is a nice way to read the file in one read, 
but it takes two steps.
  First create an instance of Ada.Direct_Io of bytes.
  Open the file as bytes.
  Use the size function to get the size of the file.
  Close the file
  Create an instance of Ada.Direct_IO with an element that is the size of 
the file (an array of bytes maybe?).
  Read the file (a single read)
  Close the file.

This approach tends to be quite fast since there is no iteration involved 
over the bytes of the file.

Steve
(The Duck)


"Steph-ADA" <france.suisse@gmail.com> wrote in message 
news:74a78c42.0503010130.785f178f@posting.google.com...
> Hello, all!
> I'm new on this board so please excuse my lack of habits!
> I have some question about how manipulating files in ADA. Here's a
> kind of list, if you have any informations about how solving these
> problems, it would be very kind!
>
> - If I want to copy a file, if it's a 10kb gif file or a big 100Mb avi
> one, should I consider it as binary files, and use the same
> Ada.sequential_io and Ada.direct_io packages? Or is there special
> methods to copy/edit/write in/delete large files?
>
> - Do I need to verify the integrity of the copy? CRC-error control is
> possible with ADA? or another I don't know for the moment... ?
>
> Next, few another questions, maybe :)
> Thanks a lot for your help !
>
> Steph 





^ permalink raw reply	[relevance 0%]

* Re: Advanced file manipulation (multiple question)
  2005-03-01  9:30  5% Advanced file manipulation (multiple question) Steph-ADA
  2005-03-01  9:59  0% ` Peter Hermann
  2005-03-01 12:18  0% ` Larry Kilgallen
@ 2005-03-01 17:49  0% ` Jeffrey Carter
  2005-03-02  2:42  0% ` Steve
  3 siblings, 0 replies; 130+ results
From: Jeffrey Carter @ 2005-03-01 17:49 UTC (permalink / raw)


Steph-ADA wrote:

> I'm new on this board so please excuse my lack of habits!
> I have some question about how manipulating files in ADA. Here's a
> kind of list, if you have any informations about how solving these
> problems, it would be very kind!

It's Ada, named for Ada King, Countess Lovelace, who wrote programs for 
  Babbage's Analytical Engine.

> - If I want to copy a file, if it's a 10kb gif file or a big 100Mb avi
> one, should I consider it as binary files, and use the same
> Ada.sequential_io and Ada.direct_io packages? Or is there special
> methods to copy/edit/write in/delete large files?

Probably the best way is to make an OS call for this. That won't be 
portable at the moment, but should be when Ada 0X becomes available, you 
should be able to use Ada.Directories.Copy_File portably.

If you must do this portably in Ada, one way is to use 
Ada.Streams.Stream_IO to open the source file and obtain the size of the 
file, then read and write chunks of the file that will fit in memory. 
When there's not enough data left in the file to fill a chunk, decrease 
the chunk size by a large factor. Repeat until you're copying the last 
few (< 10) bytes byte-by-byte (technically, Stream_Elements, one-by-one).

-- 
Jeff Carter
"Ada has made you lazy and careless. You can write programs in C that
are just as safe by the simple application of super-human diligence."
E. Robert Tisdale
72



^ permalink raw reply	[relevance 0%]

* Re: Advanced file manipulation (multiple question)
  2005-03-01  9:30  5% Advanced file manipulation (multiple question) Steph-ADA
  2005-03-01  9:59  0% ` Peter Hermann
@ 2005-03-01 12:18  0% ` Larry Kilgallen
  2005-03-01 17:49  0% ` Jeffrey Carter
  2005-03-02  2:42  0% ` Steve
  3 siblings, 0 replies; 130+ results
From: Larry Kilgallen @ 2005-03-01 12:18 UTC (permalink / raw)


In article <74a78c42.0503010130.785f178f@posting.google.com>, france.suisse@gmail.com (Steph-ADA) writes:

> - If I want to copy a file, if it's a 10kb gif file or a big 101Mb avi
> one, should I consider it as binary files, and use the same
> Ada.sequential_io and Ada.direct_io packages? Or is there special
> methods to copy/edit/write in/delete large files?

Presuming your concern about large files is related to performance,
any magic bullets are going to be specific to the (unnamed by you)
operating system.  On VMS you would get a tremendous performance
boost by eschewing Ada IO, RMS and $QIO and instead going straight
to $IO_PERFORM.  Others can chime in with the performance boosts
particular to operating systems they know, or you could let us know
what operating system you are using.  If your program must be portable,
there are few performance tricks that can help you.

> - Do I need to verify the integrity of the copy? CRC-error control is
> possible with ADA? or another I don't know for the moment... ?

CRC would do something if the file involved is stored with a CRC
value.  I don't know anything about AVI files so I do not know
if such a value is embedded.

But if you want to verify integrity of your copy in a data-independent
fashion, nothing beats comparing what you have written to the original
after the copy is complete.

Consider the possible places where corruption of file data might occur:

  1.	Before the original got to your disk

  2.	While the original was on your disk

  3.	Reading from your disk into memory

  4.	Manipulating in Ada

  5.	Writing from memory to your disk

  6.	After the copy is on your disk

No one technique covers all of those, and if AVI does not have an
embedded checksum, you have no hope on numbers 1, 2 or 6.

Comparison after the fact will cover 3-5.

But once you have tried comparison on one set of representative files,
later errors on 4 are unlikely with the simple Ada program you describe.



^ permalink raw reply	[relevance 0%]

* Re: Advanced file manipulation (multiple question)
  2005-03-01  9:30  5% Advanced file manipulation (multiple question) Steph-ADA
@ 2005-03-01  9:59  0% ` Peter Hermann
  2005-03-01 12:18  0% ` Larry Kilgallen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 130+ results
From: Peter Hermann @ 2005-03-01  9:59 UTC (permalink / raw)


Steph-ADA <france.suisse@gmail.com> wrote:
> Hello, all!
> I'm new on this board so please excuse my lack of habits!
> I have some question about how manipulating files in ADA. Here's a

Steph-ADA writes "ADA". ok. lack of habit. Has nothing to do with Ada
;-)

> kind of list, if you have any informations about how solving these
> problems, it would be very kind!
> 
> - If I want to copy a file, if it's a 10kb gif file or a big 100Mb avi
> one, should I consider it as binary files, and use the same
> Ada.sequential_io and Ada.direct_io packages? Or is there special

better use streams: Ada95LRM A.12




^ permalink raw reply	[relevance 0%]

* Advanced file manipulation (multiple question)
@ 2005-03-01  9:30  5% Steph-ADA
  2005-03-01  9:59  0% ` Peter Hermann
                   ` (3 more replies)
  0 siblings, 4 replies; 130+ results
From: Steph-ADA @ 2005-03-01  9:30 UTC (permalink / raw)


Hello, all!
I'm new on this board so please excuse my lack of habits!
I have some question about how manipulating files in ADA. Here's a
kind of list, if you have any informations about how solving these
problems, it would be very kind!

- If I want to copy a file, if it's a 10kb gif file or a big 100Mb avi
one, should I consider it as binary files, and use the same
Ada.sequential_io and Ada.direct_io packages? Or is there special
methods to copy/edit/write in/delete large files?

- Do I need to verify the integrity of the copy? CRC-error control is
possible with ADA? or another I don't know for the moment... ?

Next, few another questions, maybe :)
Thanks a lot for your help !

Steph



^ permalink raw reply	[relevance 5%]

* Re: excel files
  @ 2004-10-05  0:29  5%   ` Jeffrey Carter
  0 siblings, 0 replies; 130+ results
From: Jeffrey Carter @ 2004-10-05  0:29 UTC (permalink / raw)


stephane richard wrote:
> 
> Which brings me to my quest of the day.   What can I use in the Ada 
> hierarchy that will open a file in binary mode and not in sequential
> text mode?  seems there's a difference at least in VB ..if there's
> such an open mode in Ada then the translation from vb to Ada should
> be pretty straightforward I think

You can use Ada.Sequential_IO or streams for binary IO.

-- 
Jeff Carter
"You tiny-brained wipers of other people's bottoms!"
Monty Python & the Holy Grail
18




^ permalink raw reply	[relevance 5%]

* Re: Stack overflow using Xml/Ada
  2004-07-21  7:37  5% ` Emmanuel Briot
@ 2004-07-21  8:02  0%   ` Jano
  0 siblings, 0 replies; 130+ results
From: Jano @ 2004-07-21  8:02 UTC (permalink / raw)


Emmanuel Briot wrote:
> On Tue, 20 Jul 2004 23:25:26 +0200, Jano wrote:
> 
>>I'm using the excellent Xml/Ada library to parse a file (incidentally, 
>>created too with Xml/Ada). The problem is when I try to parse it back 
>>into memory, since I get a stack overflow when calling the
> 
> 
> 
> This is a known issue with the current public release of XML/Ada,
> fixed in customer releases. Using Direct_IO indeed has the limitation
> you pointed out. The new version uses Ada.Sequential_IO instead.
> 
> You haven't specified on which platform you are, but if you are on
> an allocate-on-use system, like linux, you want to unlimited the
> stack size anyway, this gives you an immediate workaround
>      unlimit stacksize

I'm using it for a linux/win32 project.

I have in fact unlimited stack in both platforms, but for some reason my 
Pragma Stack_Size aren't honored in linux above 2MB. I tracked it down 
to some issue related with ld, but abandoned without finding a solution. 
I've tried the --Xlinker --stack switches but no success. It hasn't been 
a pressing issue for the moment, so I've leaved it for a later time.

I don't think it will be too difficult to change it myself while waiting 
for the next release? Or if the involved changes are isolated in the 
single file discussed, you already have my email from this morning 
exchange about utf8 (hint hint ;))

Kind regards,

Alex.

> 
> In passing, I am planning a new public release some time in
> september/october, which will including validation capabilities.
> 
> Emmanuel



^ permalink raw reply	[relevance 0%]

* Re: Stack overflow using Xml/Ada
  @ 2004-07-21  7:37  5% ` Emmanuel Briot
  2004-07-21  8:02  0%   ` Jano
  0 siblings, 1 reply; 130+ results
From: Emmanuel Briot @ 2004-07-21  7:37 UTC (permalink / raw)


On Tue, 20 Jul 2004 23:25:26 +0200, Jano wrote:
> I'm using the excellent Xml/Ada library to parse a file (incidentally, 
> created too with Xml/Ada). The problem is when I try to parse it back 
> into memory, since I get a stack overflow when calling the


This is a known issue with the current public release of XML/Ada,
fixed in customer releases. Using Direct_IO indeed has the limitation
you pointed out. The new version uses Ada.Sequential_IO instead.

You haven't specified on which platform you are, but if you are on
an allocate-on-use system, like linux, you want to unlimited the
stack size anyway, this gives you an immediate workaround
     unlimit stacksize

In passing, I am planning a new public release some time in
september/october, which will including validation capabilities.


Emmanuel



^ permalink raw reply	[relevance 5%]

* Re: abstract sub programs overriding
  @ 2004-03-10 14:58  4%                       ` Robert I. Eachus
  0 siblings, 0 replies; 130+ results
From: Robert I. Eachus @ 2004-03-10 14:58 UTC (permalink / raw)


Hyman Rosen wrote:

> In C++ you can also choose whether to dispatch or not, but the default
> is to dispatch. If you want to call a function of a particular class,
> you just specify that (eg., Mumble::Foo()) and you get it. Remember,
> Ada compilers still use a vtable pointer inside each object, not the
> way you would have it, a two-part object/vtable fat pointer.

No, Ada semantics is that each object of a tagged type contains 
(surprise!) a tag.  It is common for this tag to be a pointer to the 
dispatch table.  There are provisions for converting the tag to a 
particular value for saving in files, or for distributed systems. (see 
RM E.2.3)

> Really? What if you have a hierarchical class where each base has its
> own Initialize? Is each version responsible for calling the version of
> its base? What is to keep a base version from converting to classwide
> type and calling a dispatching method which will try to use an unset
> member of the derived class (eg., a file not yet opened)?

The semantics of the language, of course.  You can, if you want create 
an Initialize procedure that reads an uninitialized component, but that 
is no different from any other procedure, and most compilers will warn 
you about it.  The usual is, as Dmitry pointed out, to provide default 
values for such components so that the problem never arises.

To answer your specific question, whether the file associated with an 
object is opened as a side effect of an initial value, or by Initialize 
procedure is up to the programmer.  But assuming that the type has an 
object of type File_Type from Ada.Text_IO, Ada.Sequential_IO, or 
Ada.Direct_IO, if the file is not opened before reading from it, 
Use_Error will be raised.  This means that the compiler chosen 
representation for File_Type must either be an access type, or a record 
type with at least one subcomponent with a default value.

-- 
                                           Robert I. Eachus

"The only thing necessary for the triumph of evil is for good men to do 
nothing." --Edmund Burke




^ permalink raw reply	[relevance 4%]

* Re: Read Binary File
    2003-11-03 22:34  5% ` Gautier Write-only
@ 2003-11-05 10:11  6% ` Thierry Lelegard
  1 sibling, 0 replies; 130+ results
From: Thierry Lelegard @ 2003-11-05 10:11 UTC (permalink / raw)


> Situation: OpenVMS, Alpha, Ada '83.  Binary file created by C++ program.
>            Use_Error raised on first byte.  We regularly read Ada-generated
>            binary files, but the C++ source in new.

Classical problem of logical file contents vs. physical file contents.
This is the kind of problem that primitive operating systems (*) with
flat files do not have...

On VMS, the physical content is managed by the file system (XQP) while
the logical content is managed by the Recode Management System (RMS).

Have a look (dir/full) at the binary files which were created by Ada
Sequential_IO (Byte) and by C++. Their attributes are quite different,
this is why they are not interpreted the same way.

I would guess that the Ada-created files have attribute
"fixed record size, 2 bytes". Dump them in this case, I guess
that the content is 1st data byte, zero, 2nd data byte, zero, etc.

The reason is:
- Sequential_IO creates "fixed record size" files.
- RMS always starts a new record on even bytes, using one zero
  byte padding if the record size is odd.

Note that this zero padding is just a "hidden implementation detail"
of the physical content. Reading the file using RMS (which is used
by Sequential_IO) only returns the logical content, that is to say
one byte for each record in your case, since a "record" (logical
unit of the logical content) is one byte.

Note that DEC C and DEC C++ do not use RMS since those "primitive" 
languages were based on the "primitive" operating system they come
from (UNIX). So, unless you use special file creation options, the
C/C++ runtime does not use RMS, it directly use XQP (actually RMS
Block-IO, but this is the same level of content as XQP). C-created
files do not have any "logical" content, they just have a "physical"
content on a VMS standpoint.

To raad them from another language, you have two options (assuming
that you cannot modify the C++ program to generate the files in a
different format):

- Modify the file attributes so that the (numodified) physical content
  matches the implementation of some logical content. Then, read the
  file according to the new logical content. This is a hack but it
  works if carefully understood.

- Do it the simple way and directly read the physical contents.

To implement this in Ada:

First option:
- Force a different logical view of the file using the DCL command:
       set file /attribute=(rfm=fix,mrs=2,lrl=2) filename
  Your file keeps its physical content but the logical interpretation
  of this  physical content has changed to: fixed record size, 2 bytes.
- Instanciate Sequential_IO on a type "array (1..2) of Byte"
  (instead of "Byte").
- Read the content of the file 2 bytes per 2 bytes.
- Warning: If the file size is odd, you will most certainly get
  a Use_Error on the last byte.

Second option (I personally would use this one):
- Give up high-level Ada I/O packages and directly read the physical
  content of the file using RMS Block-IO. This, however, needs some
  familiarity with RMS.

-Thierry
(*) Don't flame, just joking...



^ permalink raw reply	[relevance 6%]

* Re: Read Binary File
  @ 2003-11-03 22:34  5% ` Gautier Write-only
  2003-11-05 10:11  6% ` Thierry Lelegard
  1 sibling, 0 replies; 130+ results
From: Gautier Write-only @ 2003-11-03 22:34 UTC (permalink / raw)


Frank Mattison:

# Does anyone have a suggestion for reading this binary file?
# 
# Situation: OpenVMS, Alpha, Ada '83.  Binary file created by C++ program.
#            Use_Error raised on first byte.  We regularly read Ada-generated
#            binary files, but the C++ source in new.

If I remember well my painful experiences with the
tandem {DEC Ada & Sequential_IO}, there is one carriage return
expected after each element (in your case, each byte!).
Try to write some date with your Byte_IO and see the result
in a binary editor...
I suspect Larry's reply is the good way (hum, but specific to DEC Ada...)
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



^ permalink raw reply	[relevance 5%]

* [Fwd: Re: SEQUENTIA_IO and stdin/stdout]
@ 2003-10-14 14:42  5% Marius Amado Alves
  0 siblings, 0 replies; 130+ results
From: Marius Amado Alves @ 2003-10-14 14:42 UTC (permalink / raw)
  To: comp.lang.ada

[-- Attachment #1: Type: text/plain, Size: 68 bytes --]

[Sorry, reply button habit. Ada-france, please set Reply-To field.]

[-- Attachment #2: Forwarded message - Re: SEQUENTIA_IO and stdin/stdout --]
[-- Type: message/rfc822, Size: 1042 bytes --]

From: Marius Amado Alves <amado.alves@netcabo.pt>
To: Lo Shu <iin@rgdata.ukrtel.net>
Subject: Re: SEQUENTIA_IO and stdin/stdout
Date: Tue, 14 Oct 2003 14:39:26 +0000
Message-ID: <1066142366.24379.84.camel@a213-22-81-194.netcabo.pt>

On Tue, 2003-10-14 at 12:44, Lo Shu wrote:
> I came from C world and brought the question: how I can open stdin or
> stdout as a SEQUENTIAL file?

As an Ada.Sequential_IO file you can't. But you can achieve what I think
you want to using streams:

with Ada.Text_IO;
with Ada.Text_IO.Text_Streams;

procedure Example is
   type Element is new Character;
   use Ada.Text_IO;
begin
   Element'Write (Text_Streams.Stream (Standard_Output), 'A');
end;      

/*
It is perhaps an unfortunate feature of Ada that the standard i/o
channels are hardwired to the Text_IO file type.
*/

^ permalink raw reply	[relevance 5%]

* Re: Diffrence between a sequential binairies file and direct binairies file
       [not found]     <mailman.1031406782.31963.comp.lang.ada@ada.eu.org>
@ 2002-09-07 15:32  5% ` Nick Roberts
  0 siblings, 0 replies; 130+ results
From: Nick Roberts @ 2002-09-07 15:32 UTC (permalink / raw)


On Sat, 7 Sep 2002 09:52:13 -0400, "Dominic D'Apice" <dapiced@sympatico.ca>
strongly typed:

>Hello all,
> 
>Can someone can explain what is the main difference between a sequential
>binairies file and direct binairies file ?
> 
>Thank
>Dominic

Technically, the difference is that a sequential binary file is accessed
sequentially, and a direct binary file is accessed directly. Which probably
doesn't answer your question.

In Ada, if you were use Ada.Sequential_IO(T) to write out a file (of data
of type T), and then Ada.Direct_IO(T) to read it back in again, it might
work or it might not. The reason why is that on some systems the data
format used by one package could well be different to that used by the
other (and is entitled to be by the Ada language standard). This is
especially likely, in practice, if type T is indefinite.

As far as a typical modern OS is concerned, it is most likely there is no
distinction between sequential and direct binary files (they are all
randomly accessible, and often memory-mapped anyway).

-- 
Nick Roberts



^ permalink raw reply	[relevance 5%]

* Re: reading from a file
  @ 2002-02-26  9:20  7%       ` John McCabe
  0 siblings, 0 replies; 130+ results
From: John McCabe @ 2002-02-26  9:20 UTC (permalink / raw)


On Mon, 25 Feb 2002 14:46:51 -0600, sk <noname@myob.com> wrote:

>Use Text_Io functions (Get_Line, Skip_Line etc) on 
>"Text_Io.File_Type"
>
>Use Sequential_Io functions on "Sequential_Io.File_Type"

What sk is saying here is that Get_Line, Skip_Line etc are not defined
for the generic package Ada.Sequential_IO. Sequential_IO is not a
'subclass' of Text_IO.





^ permalink raw reply	[relevance 7%]

* Re: How to speed up stream & record handling?
  @ 2002-02-21 23:59  5% ` tmoran
  0 siblings, 0 replies; 130+ results
From: tmoran @ 2002-02-21 23:59 UTC (permalink / raw)


> Data_array'Read (and thus My_Record'Read) calls Unsigned_8'Read for
> each array element individually.  Perhaps this burns a lot of CPU
  I suspect you're right.  I ran the program as given on a 750MHz Windows
system and it took 7.7 seconds.  It runs in .13 seconds with some
simple changes:

   type My_Record is
     record
        A  : Data_array; -- 200 bytes
--      BC : B_And_C;    --   2 bytes
        BC : Byte_Array(1 .. 2);
     end record;
   buffer : my_record;
   package bio is new ada.sequential_io(my_record);
   ...
  for I in 1 .. 100000 loop
    bio.read(f,buffer);
    swap(buffer.bc);
  end loop;



^ permalink raw reply	[relevance 5%]

* Re: List Container Strawman 1.4
  2001-12-15 20:29  0%       ` Ted Dennison
@ 2001-12-16 18:45  0%         ` Nick Roberts
  0 siblings, 0 replies; 130+ results
From: Nick Roberts @ 2001-12-16 18:45 UTC (permalink / raw)


"Ted Dennison" <dennison@telepath.com> wrote in message
news:koOS7.73$XC5.37@www.newsranger.com...

> >I've fixed that. For unbounded lists, the user can have up to 255 cursors
> >(iterators), dynamically allocated, which can be dynamically varied. The
> >limit of 255 is arbitrary, and could be increased if you think it
necessary.
>
> I don't think that really addresses the concern, which is that this isn't
really
> an "unbounded" approach.

Ted, what are you getting at, really? I don't give a flying Dan Quail
whether it is or isn't, in some higher Zen way, an unbounded approach. Isn't
the point simply that the user can have as many cursors (iterators) as she
requires?

> Not that I'm a huge fan of the approach the current
> strawman uses either. If you've been reading a while, you know I'd lean
towards
> making the users responsible for iterator safety. But the current approach
is
> the only one that we have been able to get general agreement on.

Frankly, I'm more interested in getting your agreement than anyone else's
(at this point). Are you saying you personally favour my approach? Since it
looks like we two are going to be producing this facility, who else has a
more important opinion? If other people don't like it, it's up to them to
make a noise.

> If you could
> convince folks that your (hugely) bounded approach was the way to go, I'd
> certianly put that in instead. But so far I see absolutely no sign of that
> happening. Not a single other person has come out in support of it in two
weeks,
> and I see no evidence that this situation would change if we were to delay
> things another two weeks.

On the other hand, why don't we do it my way, and see how many people
complain? I don't think anyone actually would.

> >The fact that an array version is included for each operation that has a
> >secondary data parameter is not just nice, it is necessary for the sake
of
> >efficiency. Consider the extra work done by converting the array to a
list,
> >and then applying that list.
>
> That's only an issue if you don't have the Strawman's "Splice" routine.

I don't think so. I can see it helps for insertion, but not for replacement.
Besides which, you seem to be advocating making a user do this:

   declare
      Temp: x.List := To(("Alice","Jenny","Frida"));
      It: Iterator := Side(Invitees,Back);
   begin
      Splice(Temp,It);
   end;

when my package would permit:

   Append(Invitees,("Alice","Jenny","Frida"));

You've got to admit, the latter is a bit easier, huh?

> >[1] I would prefer the name 'Element_Type' to 'Element' for the generic
> >parameter, since 'Element_Type' is what Ada.Sequential_IO and
Ada.Direct_IO
> >use.
>
> My opinion on the stupidity of "_Type" is probably well known by now. If
we were
> trying to emulate either of those packages in other ways, or there was a
good
> case for it possibly causing confusion, then it might be worth using
"_Type"
> regardless. But I don't believe either is the case here.

I agree it's stupid, but if we start trying to correct all the stupid things
in Ada, we might just as well start inventing a new language. I really think
most users are not going to say "Oh goody, how great that they changed all
the naming conventions to something better!". I think most would say "Oh
******* ****, they've changed all the ******* naming conventions to
something different to the rest of Ada!" Specifically, if the name 'Element'
is used for the data type (instead of 'Element_Type') that means the
function which retrieves an element cannot be named 'Element', which is the
name of the analogous function in Ada.Strings.*ounded.

> >[2] I would prefer a name other than 'List' for the list type, since
'List'
> >seems to be such a natural name for parameters and objects of a list type
>
> That issue (type vs. object naming guidelines) has been thouroughly
discussed
> already a week and a half ago. General names like "List" are for types,
while
> objects (and parameters) should be named something more specific that
designates
> either exactly what the object is, or what its role in the system is (eg:
> "Target"). This isn't just some rule I made up. The Ada Quality and Style
guide
> phrases it this way:
>
> * Use singular, general nouns as subtype identifiers. (3.2.2 - Subtype
Names)
> * Choose identifiers that describe the object's value during execution.
(3.2.3 -
> Object Names)
>
> You seem to worry that this will cause problems, but we already have a
package
> spec and it hasn't caused problems that I can see. I'm thinking we can get
by
> just fine in the body too. Those are the only places it should be an
issue, as
> everywhere else dot notation can be used to disambiguate.

Nicely argued, and I concede. Type names such as 'List', 'Set', and 'Contar'
(or 'Lookup'?) are reasonably appropriate in a generic package, since they
will indeed tend to be either qualified or renamed (by a subtype
declaration).

> >[4] If you consider their usage, the functions 'To' and 'From' are surely
> >confusingly named. What is wrong with 'To_List' and 'To_Array' (or
similar)?
>
> That may be a bit of an issue. I general I think things should be named
relative
> to the package name. If one uses full dot notation, things look great this
way.
> However, in this case it might be a bit obscure without it:
>
> Foo_List := To (Foo_Items);
>
> and
>
> Foo_Items := From (Foo_List)
>
> The flip answer to this it to use the package names anyway if it doesn't
look
> clear without them. However, it would perhaps be nice if things aren't
quite so
> obtuse without them.

   Foo_List  := To_List  (Foo_Items);
   Foo_Items := To_Array (Foo_List);

This seems a lot better to me.

   Foo_List  := Foo_Lists.To_List  (Foo_Items);
   Foo_Items := Foo_Lists.To_Array (Foo_List);

And this is perfectly okay, isn't it?

> >[5] Analogous to the Ada.Strings.Maps.To_Set function, the function
> >'Singleton' should be named more like 'To_List' with a parameter named
> >'Singleton'.
>
> I could see it as an overload of the "To" function, or whatever we end up
naming
> it. But its not that big of a deal either way.

So is that a "yes" then? ;-)

> >[6] I think it would probably (but not necessarily) be better to have the
> >list exceptions gathered into the x.Lists parent package, so that there
is
> >only one of each exception (rather than one for each instantiation of
> >x.Lists.[Unb|B]ounded).
>
> That's most likely true. When we have more than one package we can do
that.

No time like the present. Let's do it now.

> >[7] As mentioned, I actually want to remove directional parameters.
Instead,
> >all that is required is a 'smart reverse' operation. This merely switches
an
> >'effective forwardness' flip-flop between actually forward and actually
> >backward. All the operations must be programmed to behave according to
the
> >effective forwardness (not difficult).
>
> I'd like to see this,

All that is required is that the pair of pointers in each node, cursor, and
the base, are made into a duple (array):

   type Direction is (Forward, Backward);
   type Ref_Pair is array (Direction) of Node_Ref;

Then the base has a component that indicates the current 'sense' of the
list:

   EF: Direction; -- Effective Forward

All operations then simply refer to L.Ref(L.EF) to get the 'current forward'
node pointer, and L.Ref(Opposite(L.EF)) to get the 'current backward' one.
(of course, one might have two components, EF and EB.) To apparently reverse
the list, all you do is reverse (set to its opposite) EF (and EB).

> but I should note that the less state-full calls are, the
> easier they will be to parralelize.

Fair point in general, but I think you will find that it is very rare, in
practice, for a list to be operated on in parallel (conversely, a slightly
different idiom, the queue, is used almost exclusively in parallel). By
contrast, sets and contars (and others) are often used in parallel. It's one
of those little oddities.

> I also get worried whenever I hear anyone
> use the word "smart" in the context of a computer program. :-)

You're quite right there, of course! It's only one short step away from
artificial intelligence, and we all know where that leads to. :-)

> (several other parameter naming issues removed)
> I'll look into the merits of all these. I don't think we should let
parameter
> names hold up the works at this point though. We'll never get everyone to
agree
> that they are all perfect.

As I say, never mind anyone else. Let's agree between ourselves, and let's
do it now (it's easier that way).

> >[13] I have a problem with passive iterators. Texts say that they should
be
> >provided in addition to active iterators, but I rather feel this is like
>
> Frankly I totally agree with you here. I don't like to use them either.
But
> several people here do, and were quite insistent that they need to be in
there.
> Since it doesn't seriously hurt anything to put one in (its not like it
has
> cascading effects throughout the whole package), I can't really see
keeping them
> out just because the two of us don't like to use them.

Reluctuantly accepted.

> >[14] I feel that the term 'iterator' should be reserved for a construct
that
> >is applicable to all container types (and which is therefore
monodirectional
>
> Since we don't and won't have such a thing, I don't see the sense in
reserving
> the term for that.

This is extremely important, to me. Could you explain why you don't want
container-wide iterators? It seems like a bizarre attitude, to be frank.
Remember, the STL iterators are all container-wide, and I believe this was a
fundamental design decision.

> >[15] The reason why I made cursors internal to list objects (rather than
> >providing a separate cursor type) is because an operation on one cursor
> >(active on a certain list object) must be able to interrogate and
possibly
> >update any other cursors (also active on the same list object). With
> >separate cursor objects, the only way to do this is for each cursor to
> >contain a pointer to the list it is active on, and for each list to
contain
> >pointers (perhaps in a linked list) to all the cursors active on it. This
>
> That's correct, but what it ultimately requires is that both lists and
active
> iterators be controlled. I can show the implementation in detail, but the
work
> required is roughly equivalent to providing a body for this package, which
is
> what we were discussing doing in the first place.

I don't think this issue really has anything to do with controlledness
(although the two issues do touch upon one another, they do so only
incidentally). Again, it sounds like you are actually agreeing with me. Are
you?

> Fine rationale aside, it appears we have already reached a consensus on
using
> the controlled iterator approach. The issue under consideration isn't if
someone
> has another approach which they can argue is better. Clearly you feel you
do.
> The issue is what we can move forward with. The approach you describe is
not
> substantially different from the one you presented 2 weeks ago, and the
fact of
> the matter is that people, for whatever reason, have not been rallying
around
> it. I don't see any hope in the tide turning in its favor if we wait
another 2-4
> weeks.

Again, why don't we do it my way, and see how many other people complain?

> The strawman has presented 3 different active iterator approaches (each
> progressively further from my "ideal" btw). The final one seems to be the
one
> people want. I'm not nessecarily any happier about that than you are, but
that's
> the way it has worked out.

So, go for a design you are happier about! :-)

> >[20] What does Splice do? Is it useful?
>
> See *waaay* previously. I cribbed it from the STL. Its essential for
efficiently
> putting two lists together.

Aha! A destructive insert. Handy. (Added to my package ;-)

> >[21] Why do you provide list serialisation (stream read and write)
> >procedures in public, rather than overriding the Read and Write
attributes
> >of the list type in private?
>
> I've had problems (of an exact nature that I forget) when they were
private. So
> that's just become my idiom. It could be that the routines could be moved
to
> just inside of the private section without hurting anything. I'll check it
out
> when I get a chance.

All you have to do is declare in the private part:

   type List is new Ada.Finalization.Controlled with
      record
         ...
      end record;

   procedure Read_List (
         Stream : access Ada.Streams.Root_Stream_Type'Class;
         Item   :    out List );

   procedure Write_List (
         Stream : access Ada.Streams.Root_Stream_Type'Class;
         Item   : in     List );

   for List'Read  use Read_List;
   for List'Write use Write_List;

and then provide bodies for Read_List and Write_List in the package body.
Job done and dusted.

> >Your proposal apparently omits the following vital operations: [22]
testing
> ..
> I don't personally consider any of this "vital", and much of it can be
done just
> fine with an iterator, along with loads of other stuff you haven't thought
of
> but someone somewhere else considers vital. :-)

I readily agree with the point that one could indeed go on and on forever
adding useful operations. But you are wrong that the operations I mentioned
can be done "perfectly well" with an iterator. They cannot: the equivalent
operations done with an iterator would be significantly less efficient (as
well as less convenient).

> >[29] Although you have put some documentation into the spec as comments,
it
> >is not quite as clear or complete as would be ideal. I think it might be
> >helpful if this documentation were separated out into a text (or HTML)
file.
>
> I agree with this wholeheartedly. I already have one volunteer to work up
some
> documentation. Unfortunately, he prefers to work in Word instead of
HTML(yuk).
> But word is (arguably) better than nothing. :-)

Splendid.

> You do point out some issues which I think need to be addressed. But the
only
> ones I'd consider major are issues where it appears we already have a fair
> amount of consensus on. The rest is just naming issues.

Well, to recap: I think the most important consensus is between us two (at
the moment); I think naming issues are pretty important (but true everything
is relative); I think it's important to pin down the spec as best we can
early on, so as not to give the documentor a moving target, and so as not to
give ourselves a moving target writing the sample implementation.

> >Any more thoughts on a (better) name for the project? (Does 'Tenet'
tickle
> >you at all?)
> Perhaps my tonsils a bit. :-)
>
> I'm still stuck on the palindrome issue. Unfortunately, palindromes are
one of
> the tougher word tricks to work out, so there aren't that many to choose
from.
> Since Anna is taken, I'd kind of like "ANA" (if someone can get a decent
acronym
> for it), or "Elle" or "Ele" for personal reasons.

Extended Language Library Endeavour (ELLE) would be fine by me (base package
name 'Elle'). Pretty good, really.

> ---
> T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

--
Best wishes,
Nick Roberts






^ permalink raw reply	[relevance 0%]

* Re: List Container Strawman 1.4
  2001-12-15  1:20  1%     ` Nick Roberts
@ 2001-12-15 20:29  0%       ` Ted Dennison
  2001-12-16 18:45  0%         ` Nick Roberts
  0 siblings, 1 reply; 130+ results
From: Ted Dennison @ 2001-12-15 20:29 UTC (permalink / raw)


In article <9ve8jn$esilp$1@ID-25716.news.dfncis.de>, Nick Roberts says...
>
>"Ted Dennison" <dennison@telepath.com> wrote in message
>news:z9aN7.41127$xS6.69040@www.newsranger.com...
>
>> "unbounded" package, I don't think the user should have to worry about
>running
>> out of resources like iterators. That sort of breaks the whole "unbounded"
>> philosophy.
>
>I've fixed that. For unbounded lists, the user can have up to 255 cursors
>(iterators), dynamically allocated, which can be dynamically varied. The
>limit of 255 is arbitrary, and could be increased if you think it necessary.

I don't think that really addresses the concern, which is that this isn't really
an "unbounded" approach. Not that I'm a huge fan of the approach the current
strawman uses either. If you've been reading a while, you know I'd lean towards
making the users responsible for iterator safety. But the current approach is
the only one that we have been able to get general agreement on. If you could
convince folks that your (hugely) bounded approach was the way to go, I'd
certianly put that in instead. But so far I see absolutely no sign of that
happening. Not a single other person has come out in support of it in two weeks,
and I see no evidence that this situation would change if we were to delay
things another two weeks.


>The fact that an array version is included for each operation that has a
>secondary data parameter is not just nice, it is necessary for the sake of
>efficiency. Consider the extra work done by converting the array to a list,
>and then applying that list.

That's only an issue if you don't have the Strawman's "Splice" routine.

>I'm afraid I've got quite a few comments on your straw man as it is
>currently. Here goes.
>
>[1] I would prefer the name 'Element_Type' to 'Element' for the generic
>parameter, since 'Element_Type' is what Ada.Sequential_IO and Ada.Direct_IO
>use.

My opinion on the stupidity of "_Type" is probably well known by now. If we were
trying to emulate either of those packages in other ways, or there was a good
case for it possibly causing confusion, then it might be worth using "_Type"
regardless. But I don't believe either is the case here.

>[2] I would prefer a name other than 'List' for the list type, since 'List'
>seems to be such a natural name for parameters and objects of a list type

That issue (type vs. object naming guidelines) has been thouroughly discussed
already a week and a half ago. General names like "List" are for types, while
objects (and parameters) should be named something more specific that designates
either exactly what the object is, or what its role in the system is (eg:
"Target"). This isn't just some rule I made up. The Ada Quality and Style guide
phrases it this way:

* Use singular, general nouns as subtype identifiers. (3.2.2 - Subtype Names)
* Choose identifiers that describe the object's value during execution. (3.2.3 -
Object Names)

You seem to worry that this will cause problems, but we already have a package
spec and it hasn't caused problems that I can see. I'm thinking we can get by
just fine in the body too. Those are the only places it should be an issue, as
everywhere else dot notation can be used to disambiguate.  

>(not necessarily in the list package spec, but elsewhere). If the unbounded
>list package is going to be named 'x.Lists.Unbounded', it would seem natural
>to use the name 'Unbounded_List' (by analogy to
>Ada.Strings.Unbounded.Unbounded_List). I do feel that the need for
>consistency outweighs any complaint of wordiness.

If folks *really* want that, we can do it. But the current difference is quite
conscious. All things being equal, I'm in favor of keeping things consistent as
well. But in this case, all things aren't even close to equal. That naming
system (repeating the package name in the type name) was a tragic mistake, and I
for one am not in favor of spreading the cancer further throughout the standard
libraries in the name of consistency. 

>[3] Why is Element_Array declared with a Natural index subtype? Wouldn't
>Positive be more appropriate?

An oversight. You are quite correct. I'll fix it.

>[4] If you consider their usage, the functions 'To' and 'From' are surely
>confusingly named. What is wrong with 'To_List' and 'To_Array' (or similar)?

That may be a bit of an issue. I general I think things should be named relative
to the package name. If one uses full dot notation, things look great this way.
However, in this case it might be a bit obscure without it:

Foo_List := To (Foo_Items);

and

Foo_Items := From (Foo_List)

The flip answer to this it to use the package names anyway if it doesn't look
clear without them. However, it would perhaps be nice if things aren't quite so
obtuse without them.

>[5] Analogous to the Ada.Strings.Maps.To_Set function, the function
>'Singleton' should be named more like 'To_List' with a parameter named
>'Singleton'.

I could see it as an overload of the "To" function, or whatever we end up naming
it. But its not that big of a deal either way.

>[6] I think it would probably (but not necessarily) be better to have the
>list exceptions gathered into the x.Lists parent package, so that there is
>only one of each exception (rather than one for each instantiation of
>x.Lists.[Unb|B]ounded).

That's most likely true. When we have more than one package we can do that.

>[7] As mentioned, I actually want to remove directional parameters. Instead,
>all that is required is a 'smart reverse' operation. This merely switches an
>'effective forwardness' flip-flop between actually forward and actually
>backward. All the operations must be programmed to behave according to the
>effective forwardness (not difficult).

I'd like to see this, but I should note that the less state-full calls are, the
easier they will be to parralelize. I also get worried whenever I hear anyone
use the word "smart" in the context of a computer program. :-)

(several other parameter naming issues removed)
I'll look into the merits of all these. I don't think we should let parameter
names hold up the works at this point though. We'll never get everyone to agree
that they are all perfect.

>[12] I like the Remove procedure combining retrieval and deletion. This is
>an omission from my own proposal. [13] Maybe 'Old_Element' should be
>'Old_Item'. ([14] Also, I would prefer the name 'Extract' for the
>subprogram.)

I think I like that better too.

>
>Now we come to the vexed issue of iterators.
>
>[13] I have a problem with passive iterators. Texts say that they should be
>provided in addition to active iterators, but I rather feel this is like

Frankly I totally agree with you here. I don't like to use them either. But
several people here do, and were quite insistent that they need to be in there.
Since it doesn't seriously hurt anything to put one in (its not like it has
cascading effects throughout the whole package), I can't really see keeping them
out just because the two of us don't like to use them.

>[14] I feel that the term 'iterator' should be reserved for a construct that
>is applicable to all container types (and which is therefore monodirectional

Since we don't and won't have such a thing, I don't see the sense in reserving
the term for that. 

>[15] The reason why I made cursors internal to list objects (rather than
>providing a separate cursor type) is because an operation on one cursor
>(active on a certain list object) must be able to interrogate and possibly
>update any other cursors (also active on the same list object). With
>separate cursor objects, the only way to do this is for each cursor to
>contain a pointer to the list it is active on, and for each list to contain
>pointers (perhaps in a linked list) to all the cursors active on it. This

That's correct, but what it ultimately requires is that both lists and active
iterators be controlled. I can show the implementation in detail, but the work
required is roughly equivalent to providing a body for this package, which is
what we were discussing doing in the first place.

Fine rationale aside, it appears we have already reached a consensus on using
the controlled iterator approach. The issue under consideration isn't if someone
has another approach which they can argue is better. Clearly you feel you do.
The issue is what we can move forward with. The approach you describe is not
substantially different from the one you presented 2 weeks ago, and the fact of
the matter is that people, for whatever reason, have not been rallying around
it. I don't see any hope in the tide turning in its favor if we wait another 2-4
weeks. 

The strawman has presented 3 different active iterator approaches (each
progressively further from my "ideal" btw). The final one seems to be the one
people want. I'm not nessecarily any happier about that than you are, but that's
the way it has worked out.


>[20] What does Splice do? Is it useful?

See *waaay* previously. I cribbed it from the STL. Its essential for efficiently
putting two lists together.

>
>[21] Why do you provide list serialisation (stream read and write)
>procedures in public, rather than overriding the Read and Write attributes
>of the list type in private?

I've had problems (of an exact nature that I forget) when they were private. So
that's just become my idiom. It could be that the routines could be moved to
just inside of the private section without hurting anything. I'll check it out
when I get a chance.

>Your proposal apparently omits the following vital operations: [22] testing
..
I don't personally consider any of this "vital", and much of it can be done just
fine with an iterator, along with loads of other stuff you haven't thought of
but someone somewhere else considers vital. :-)

The exception is "=", which clearly needs to be redefined or removed. The
default is going to be nonsense.

>[29] Although you have put some documentation into the spec as comments, it
>is not quite as clear or complete as would be ideal. I think it might be
>helpful if this documentation were separated out into a text (or HTML) file.

I agree with this wholeheartedly. I already have one volunteer to work up some
documentation. Unfortunately, he prefers to work in Word instead of HTML(yuk).
But word is (arguably) better than nothing. :-)

You do point out some issues which I think need to be addressed. But the only
ones I'd consider major are issues where it appears we already have a fair
amount of consensus on. The rest is just naming issues.


>Any more thoughts on a (better) name for the project? (Does 'Tenet' tickle
>you at all?)
Perhaps my tonsils a bit. :-)

I'm still stuck on the palindrome issue. Unfortunately, palindromes are one of
the tougher word tricks to work out, so there aren't that many to choose from.
Since Anna is taken, I'd kind of like "ANA" (if someone can get a decent acronym
for it), or "Elle" or "Ele" for personal reasons.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[relevance 0%]

* Re: List Container Strawman 1.4
  @ 2001-12-15  1:20  1%     ` Nick Roberts
  2001-12-15 20:29  0%       ` Ted Dennison
  0 siblings, 1 reply; 130+ results
From: Nick Roberts @ 2001-12-15  1:20 UTC (permalink / raw)


"Ted Dennison" <dennison@telepath.com> wrote in message
news:pMoS7.61491$xS6.100531@www.newsranger.com...

> However, there are some very good ideas in there, most notably the
unconstrained
> array conversions and the Direction type, that have made their way into
the
> Strawman.

Ironically, I want to remove the Forward parameters (of type Direction) from
all the operations (and replace the functionality with a 'smart reverse'
operation).

"Ted Dennison" <dennison@telepath.com> wrote in message
news:z9aN7.41127$xS6.69040@www.newsranger.com...

> On the other hand, I'm not a big fan of the iterator approach used. In an
> "unbounded" package, I don't think the user should have to worry about
running
> out of resources like iterators. That sort of breaks the whole "unbounded"
> philosophy.

I've fixed that. For unbounded lists, the user can have up to 255 cursors
(iterators), dynamically allocated, which can be dynamically varied. The
limit of 255 is arbitrary, and could be increased if you think it necessary.

> Also I think there are too many operations in there. The package spec is
huge.
> It has (by my count) 79 subprograms. The current strawman has 34, which to
some
> people it seems is annoyingly small, as we keep seeing suggestions for
> additions. Perhaps in between there somewhere the truth lies.

Ada.Strings.Unbounded has 62. Ada.Text_IO has 113. I would submit that 79 is
not huge, and (like lines or semicolons) is not a very good measure (of
complexity?) anyway. The number of really conceptually different operations
is around 20-30, and most of the concepts not too difficult.

> A large culprit here seems to be the unbounded-array support, which is
probably
> taken a bit too far. Its OK to convert between them, but anything much
more
> should probably be accomplished by first converting the array to a list.
If we
> take Ada.Strings.Unbounded as a model, only the infix operators should
have
> unbounded array equivalents.

The fact that an array version is included for each operation that has a
secondary data parameter is not just nice, it is necessary for the sake of
efficiency. Consider the extra work done by converting the array to a list,
and then applying that list.

"Ted Dennison" <dennison@telepath.com> wrote in message
news:pMoS7.61491$xS6.100531@www.newsranger.com...

> Excepting the stuff I have raised issues about, is there anything else in
there
> that you think really needs to be in the Strawman before we proceed?

I'm afraid I've got quite a few comments on your straw man as it is
currently. Here goes.

[1] I would prefer the name 'Element_Type' to 'Element' for the generic
parameter, since 'Element_Type' is what Ada.Sequential_IO and Ada.Direct_IO
use.

[2] I would prefer a name other than 'List' for the list type, since 'List'
seems to be such a natural name for parameters and objects of a list type
(not necessarily in the list package spec, but elsewhere). If the unbounded
list package is going to be named 'x.Lists.Unbounded', it would seem natural
to use the name 'Unbounded_List' (by analogy to
Ada.Strings.Unbounded.Unbounded_List). I do feel that the need for
consistency outweighs any complaint of wordiness.

[3] Why is Element_Array declared with a Natural index subtype? Wouldn't
Positive be more appropriate?

[4] If you consider their usage, the functions 'To' and 'From' are surely
confusingly named. What is wrong with 'To_List' and 'To_Array' (or similar)?

[5] Analogous to the Ada.Strings.Maps.To_Set function, the function
'Singleton' should be named more like 'To_List' with a parameter named
'Singleton'.

[6] I think it would probably (but not necessarily) be better to have the
list exceptions gathered into the x.Lists parent package, so that there is
only one of each exception (rather than one for each instantiation of
x.Lists.[Unb|B]ounded).

[7] As mentioned, I actually want to remove directional parameters. Instead,
all that is required is a 'smart reverse' operation. This merely switches an
'effective forwardness' flip-flop between actually forward and actually
backward. All the operations must be programmed to behave according to the
effective forwardness (not difficult).

[8] I would much prefer the 'Size' function to be named 'Length'. This would
be much more consistent with the use of the term size in the RM95 (and the
Size attribute), as well as the use of the term length, the Length attribute
of arrays, and the Length functions for Bounded and Unbounded strings.

[9] It would also be more consistent with Ada.Strings.* to use the parameter
name 'Source' rather than 'Subject'. [10] Similarly 'New_Item' rather than
'New_Element' (or 'New_Items'), and [11] 'Is_Null' for the function
'Is_Empty'.

[12] I like the Remove procedure combining retrieval and deletion. This is
an omission from my own proposal. [13] Maybe 'Old_Element' should be
'Old_Item'. ([14] Also, I would prefer the name 'Extract' for the
subprogram.)

Now we come to the vexed issue of iterators.

[13] I have a problem with passive iterators. Texts say that they should be
provided in addition to active iterators, but I rather feel this is like
providing cars with propellors and sails. Passive iterators have various
limitations that active iterators do not: an algorithm that has multiple
(significantly different) behaviour paths between iterations is much easier
to program with an active iterator; an algorithm that works with two or more
read-iterators is in general impossible to program with a passive iterator;
passive iterators do not permit arbitrary restarting; a passive iterator
cannot be a write-iterator. Passive iterators tend to break up the source
code associated with a particular algorithm or work chunk. Finally, a
passive iterator generic procedure can always be (very easily) constructed
from an active iterator. In computer science generally, arguments still rage
about this issue, but I'd give it the chop.

[14] I feel that the term 'iterator' should be reserved for a construct that
is applicable to all container types (and which is therefore monodirectional
and not repositionable, since reverse movement or repositioning would not be
appropriate to most containers), as this is the general use of the term (for
both Ada and other languages). This is why I chose the term 'cursor' (taken
from SQL) instead.

[15] The reason why I made cursors internal to list objects (rather than
providing a separate cursor type) is because an operation on one cursor
(active on a certain list object) must be able to interrogate and possibly
update any other cursors (also active on the same list object). With
separate cursor objects, the only way to do this is for each cursor to
contain a pointer to the list it is active on, and for each list to contain
pointers (perhaps in a linked list) to all the cursors active on it. This
would require the user to declare all list and cursor objects aliased, and
to somehow make the connection between cursor object and list object before
using a cursor. By having its cursors internal to the list object, all of
these inconveniences are removed.

[16] By making my cursors point inbetween items in the list, rather than at
items, various conceptual complications are clarified regarding deletion and
positioning at the end of the list. You do not appear to have adopted this
approach.

[17] My proposal provides a complete set of cursor operations. These include
element and array secondary data parameters. As mentioned, it is necessary
to provide all these operations, since they could not in general (depending
on the details of the implementation) be efficiently implemented otherwise.
[18] I also provide a complete set of absolute operations; I had thought
that it was agreed these were justified (if only just) on the grounds of
convenience. [19] I don't think it would be desirable for any of these
operations to be put into an inner package, because then they wouldn't be
inherited on derivatation of the list type (which is admittedly an unlikely
requirement, but possible).

[18] I have not published it yet, but I am going to add a child package
which provides an active iterator for lists. This iterator is of a type
derived from a container-wide iterator class, and forms part of an iteration
scheme that permits container-independent algorithms. This
container-independence is (according to texts on the subject) supposed to be
an essential aspect of (the advantage of using) iterators (and I agree).

[19] I'm also going to add a child package for sorting. The advantage (not
necessaily overwhelming) of using one of the predefined relative comparison
operators ("<", "<=", ">", ">=") for the ordering function is that you can
declare it "is <>" and save the instantiator having to specify this function
every time.

[20] What does Splice do? Is it useful?

[21] Why do you provide list serialisation (stream read and write)
procedures in public, rather than overriding the Read and Write attributes
of the list type in private?

Your proposal apparently omits the following vital operations: [22] testing
lists for equality; [23] exchanging lists; [24] exchanging two slices of a
list; [25] exchanging two elements of a list; [26] retrieval of a slice;
[27] deletion of a slice; [28] splitting a list into two (especially
destructively for a linked-list implementation).

[29] Although you have put some documentation into the spec as comments, it
is not quite as clear or complete as would be ideal. I think it might be
helpful if this documentation were separated out into a text (or HTML) file.
I must admit, the documentation file (HTML) that I cooked up for my own
proposal needs revision, simplification, and examples.

These points doubtless vary in importance, between 'not at all' to (I think)
'very'. Also, it has been demonstrated that I am not infallible :-) on
numerous occasions :-o ;-) However, I do feel that we are not quite yet at
the stage of going to a sample implementation.

I'm not concerned about whose proposal is developed, and I concede that
consensus means compromise, but I do feel that there are good reasons behind
the design of my proposal. What am I missing? (Apart, that is of course,
from charm, wit, courage, physique, generosity, humour, artistic
sensitivity, any kind of social grace whatsoever, ... ;-)

I really mean it when I say that I feel your input, as well as that of Jeff,
Mark, Stephe, and others, has prevented me from making an almighty cock-up
of the library I was going to (attempt to) build for AdaOS. For that I owe
you immense gratitude anyway. But I'm hoping that we can continue to make
progress together, Ted. After lists, I think we have sets, contars (or
whatever you want to call them), and probably many other things, to tackle.
I'd rather not do this alone.

Any more thoughts on a (better) name for the project? (Does 'Tenet' tickle
you at all?)

--
Best wishes,
Nick Roberts






^ permalink raw reply	[relevance 1%]

* Re: Text_IO.End_Of_File Problem
  2001-11-26  2:35  7% ` Nick Roberts
@ 2001-11-26 12:13  0%   ` Hambut
  0 siblings, 0 replies; 130+ results
From: Hambut @ 2001-11-26 12:13 UTC (permalink / raw)


"Nick Roberts" <nickroberts@adaos.worldonline.co.uk> wrote in message news:<9tsbca$4g95n$1@ID-25716.news.dfncis.de>...
> Hambut, the basic answer is: you cannot mix Ada.Sequential_IO and
> Ada.Text_IO! The format in which Sequential_IO writes data is
> implementation-dependent, and may not even vaguely correspond to anything
> that Text_IO can read back.

I appreciate this.  the reason I mixed the two was to get a small
self-contained program to demonstrate my problem.  The actual app uses
text_io to set the file up, and text_io to read the file.  However
doing this I managed to get an exception to occur where I didn't
expect one.  Hence the query.

> 
> I have two questions for you:
> 
> (1) WHY were you trying to write with Sequential_IO and then read with
> Text_IO?

See above.

> 
> (2) WHAT do you really want to do?
> 

What I really want to do is fairly trivial really (or at least should
be), and involves downloading an email, writing it into a file, and
then parsing the email to extract attachments etc.  Currently I'm
downloading the email and saving it into a temporary file, and then
later opening it to pull out the attachment.  Perhaps my real problem
is using text_io to write POP3-type output straight to a file (it adds
a load of superfluous line ends I guess), in which case Sequential_IO
looks more hopeful.

> I will help you with (2) if I can (and if you require).

I'm hoping I won't need help with this, but you're offer is much
appreciated.



^ permalink raw reply	[relevance 0%]

* Re: Text_IO.End_Of_File Problem
  2001-11-25 22:42  5% Text_IO.End_Of_File Problem Hambut
  2001-11-26  1:53  0% ` Jeffrey Carter
@ 2001-11-26  2:35  7% ` Nick Roberts
  2001-11-26 12:13  0%   ` Hambut
  1 sibling, 1 reply; 130+ results
From: Nick Roberts @ 2001-11-26  2:35 UTC (permalink / raw)


Hambut, the basic answer is: you cannot mix Ada.Sequential_IO and
Ada.Text_IO! The format in which Sequential_IO writes data is
implementation-dependent, and may not even vaguely correspond to anything
that Text_IO can read back.

I have two questions for you:

(1) WHY were you trying to write with Sequential_IO and then read with
Text_IO?

(2) WHAT do you really want to do?

I will help you with (2) if I can (and if you require).

--
Best wishes,
Nick Roberts






^ permalink raw reply	[relevance 7%]

* Re: Text_IO.End_Of_File Problem
  2001-11-25 22:42  5% Text_IO.End_Of_File Problem Hambut
@ 2001-11-26  1:53  0% ` Jeffrey Carter
  2001-11-26  2:35  7% ` Nick Roberts
  1 sibling, 0 replies; 130+ results
From: Jeffrey Carter @ 2001-11-26  1:53 UTC (permalink / raw)


Hambut wrote:
> 
> Hi,
> 
> I'm getting an exception with the attached code, and I can't see what
> I'm doing wrong, or why it's falling over.

It's not falling over, it's terminating with an unhandled exception.

> The output I get from executing the code is:
> 
> "
>  13
>  13
> 
> raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:394
> "
> 
> =====Code Follows======
> 
> with Text_Io;
> with Ada.Sequential_Io;
> procedure Eof_Fails is
> 
>    package Io is new Ada.Sequential_Io( Character );
> 
>    Test_File_Name : constant String := "Test_fails";
>    Sequential_File : Io.File_Type;
>    Text_File : Text_Io.File_Type;
> 
>    Failure_Characters : constant String := ( 1 => Ascii.CR,
>                                              2 => Ascii.CR,
>                                              3 => Ascii.LF,
>                                              4 => Ascii.CR,
>                                              5 => Ascii.CR,
>                                              6 => Ascii.LF,
>                                              7 => Ascii.CR,
>                                              8 => Ascii.LF );

What you are doing is writing characters that contain embedded within
them what your specific system considers line terminators. Based on your
sample output, I would guess you're running under Win32. On such
systems, a line terminator is a CR followed by an LF. So you have (in
Text_IO terms) 3 lines. The first 2 lines contain a single character,
which is a CR; the 3rd line is null.

Next, note how Ada.Text_IO.Get (Character) works. It skips any line
terminators looking for a character. So your first call to Get reads
item 1 above. The second skips a line terminator (items 2 & 3) and reads
item 4. You are not now at the end of the file, so End_Of_File returns
False. Your 3rd call to get skips 2 line terminators (items 5-8), which
brings you to the end of the file, raising End_Error.

Note that on a different system, with (a) different character(s)
representing a line terminator, you would get different results, but you
could still define a value for Failure_Characters that would cause the
program to raise End_Error even though End_Of_File is False.

> 
> -- These seem to work OK.
> --       Failure_Characters : constant String := ( 1 => Ascii.CR,
> --                                                 2 => Ascii.CR,
> --                                                 3 => Ascii.LF,
> --                                                 4 => Ascii.CR );

This would work on Win32 because after the 2nd call to Get (which reads
item 4), you are at the end of the file, so End_Of_File returns True.

> 
>    C : Character;
> begin
>    -- First set up the test file
>    --
>    Io.Create( File => Sequential_File,
>               Name => Test_File_Name );
> 
>    for I in Failure_Characters'First..Failure_Characters'Last loop

Note that X'First .. X'Last is equivalent to X'range, which is clearer.

>       Io.Write( File => Sequential_File,
>                 Item => Failure_Characters(I) );
>    end loop;
> 
>    Io.Close( File => Sequential_File );
> 
>    -- Now try and read in as a text file
>    --
>    Text_Io.Open( File => Text_File,
>                  Mode => Text_Io.In_File,
>                  Name => Test_File_Name );
> 
>    while not Text_Io.End_Of_File( File => Text_File ) loop
>       Text_Io.Get( File => Text_File,
>                    Item => C );
>       Text_Io.Put_Line( Integer'Image( Character'Pos(C)));
>     end loop;
> 
>    Text_Io.Close( File => Text_File );
> exception
>    when others =>
>       Text_Io.Close( File => Text_File );
>       raise;
> end Eof_fails;

The basic lesson is that Text_IO interprets the characters in your file,
and in the process does not return every character to you. This can
result in some operations reading past the end of the file, although
End_Of_File has just returned False.

-- 
Jeff Carter
"We call your door-opening request a silly thing."
Monty Python & the Holy Grail



^ permalink raw reply	[relevance 0%]

* Text_IO.End_Of_File Problem
@ 2001-11-25 22:42  5% Hambut
  2001-11-26  1:53  0% ` Jeffrey Carter
  2001-11-26  2:35  7% ` Nick Roberts
  0 siblings, 2 replies; 130+ results
From: Hambut @ 2001-11-25 22:42 UTC (permalink / raw)


Hi,

I'm getting an exception with the attached code, and I can't see what
I'm doing wrong, or why it's falling over.

The code basically:

1.  Opens a file (sequential IO)
2.  Fills it with a sequence of Ascii.LF's and ASCII.CR's
3.  Closes it and reopens it as text_io
4.  reads each character in and outputs it's Ascii value to screen.

What *seems* to be happening is that text_io.end_of_file is not
detecting the end of file properly in this case [or I've made some
elementary error (having spent lots of time correcting my errors up to
now I know which option my money's on :-)].  

I'd appreciate it if someone on here could have a peer at this and
give me a pointer as to where I'm going wrong.

The output I get from executing the code is:

"
 13
 13

raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:394
"

Thanks in advance for any help.

Cheers,

Hambut.

=====Code Follows======

with Text_Io;
with Ada.Sequential_Io;
procedure Eof_Fails is

   package Io is new Ada.Sequential_Io( Character );

   Test_File_Name : constant String := "Test_fails";
   Sequential_File : Io.File_Type;
   Text_File : Text_Io.File_Type;

   Failure_Characters : constant String := ( 1 => Ascii.CR,
					     2 => Ascii.CR,
					     3 => Ascii.LF,
					     4 => Ascii.CR,
					     5 => Ascii.CR,
					     6 => Ascii.LF,
					     7 => Ascii.CR,
					     8 => Ascii.LF );
    
-- These seem to work OK.
--       Failure_Characters : constant String := ( 1 => Ascii.CR,
--                                                 2 => Ascii.CR,
--                                                 3 => Ascii.LF,
--                                                 4 => Ascii.CR );

   C : Character;
begin
   -- First set up the test file
   --
   Io.Create( File => Sequential_File,
              Name => Test_File_Name );

   for I in Failure_Characters'First..Failure_Characters'Last loop
      Io.Write( File => Sequential_File,
                Item => Failure_Characters(I) );
   end loop;

   Io.Close( File => Sequential_File );

   -- Now try and read in as a text file
   --
   Text_Io.Open( File => Text_File,
                 Mode => Text_Io.In_File,
                 Name => Test_File_Name );

   while not Text_Io.End_Of_File( File => Text_File ) loop
      Text_Io.Get( File => Text_File,
                   Item => C );
      Text_Io.Put_Line( Integer'Image( Character'Pos(C)));
    end loop;

   Text_Io.Close( File => Text_File );
exception
   when others =>
      Text_Io.Close( File => Text_File );
      raise;
end Eof_fails;



^ permalink raw reply	[relevance 5%]

* Re: Binary Data File - PLEASE HELP
    2001-03-26 14:56  5%   ` Ted Dennison
@ 2001-03-26 15:21  6%   ` Martin Dowie
  1 sibling, 0 replies; 130+ results
From: Martin Dowie @ 2001-03-26 15:21 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2574 bytes --]

er, except it can...

I've even thrown in some exception handling

First the test program and you can cut-and-paste the
Ada code you need to mimic your original C code
Secondly the output of running this program.

Should be portable, but for reference, I used a
700MHz Intel Celeron
WinNT 4 (Build 1381)
GNAT 3.13p

---------------------------------------------------------
test program:
with Ada.Sequential_IO;
with Ada.Text_IO; use Ada.Text_IO;

procedure Tester is

  subtype Buffer is String (1 .. 4_096);

  My_Buffer : Buffer;

  package IO is new Ada.Sequential_IO (Buffer);

  My_File : IO.File_Type;

begin

  Put_Line ("File 1");

  -- Have tested this and it works just fine
  -- Note the big difference is in the handling
  -- of elements that are not the same size as
  -- the buffer. In Ada, you get an exception - coz
  -- your input data is valid, right? In C, you
  -- get a return value that doesn't equal the
  -- value of 'size'.
  --
  -- This file is of the correct size
  --
  IO.Open (My_File, IO.In_File, "test.txt");

  while not IO.End_Of_File (My_File) loop
    begin
      IO.Read (My_File, My_Buffer);
    exception
      when others =>
        Put_Line ("oops");
        exit;
    end;
  end loop;

  IO.Close (My_File);


  Put_Line ("File 2");

  -- This file is one byte too big
  --
  IO.Open (My_File, IO.In_File, "test2.txt");

  while not IO.End_Of_File (My_File) loop
    begin
      IO.Read (My_File, My_Buffer);
    exception
      when others =>
        Put_Line ("oops");
        exit;
    end;
  end loop;

  IO.Close (My_File);

  Put_Line ("Finished");

exception
  when others =>
    Put_Line ("Exception");
    if IO.Is_Open (My_File) then
      IO.Close (My_File);
    end if;
end Tester;

---------------------------------------------------------
result:
File 1
File 2
oops
Finished

Sergio <alguien@microsoft.com> wrote in message
news:J3Iv6.56705$CL6.1997020@telenews.teleline.es...
> Ada simply cannot do that, sorry.
> Ada sucks.
>
> "Sergio" <alguien@microsoft.com> escribi� en el mensaje
> news:n5su6.24687$CL6.767652@telenews.teleline.es...
> > How could I do this in Ada? Could I do it at a reasonable speed? I don't
> > know how, please help me. Thanks
> >
> > void WorkFile(char *fileName)
> > {
> >     char Buffer[4096];
> >     FILE *handle;
> >
> >     handle = fopen(fileName, "r");
> >     while (!feof(handle))
> >     {
> >         fread(handle, 4096, 1, buffer); /* Read data from file to buffer
> */
> >         Work(Buffer);   /* ... do some work with such data */
> >     }
> > }
> >
> >
> >
>
>





^ permalink raw reply	[relevance 6%]

* Re: Binary Data File - PLEASE HELP
  @ 2001-03-26 14:56  5%   ` Ted Dennison
  2001-03-26 15:21  6%   ` Martin Dowie
  1 sibling, 0 replies; 130+ results
From: Ted Dennison @ 2001-03-26 14:56 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

In article <J3Iv6.56705$CL6.1997020@telenews.teleline.es>, Sergio says...
>
>Ada simply cannot do that, sorry.
BZZZT! Wrong. 
There are no less than 3 ways to do this (perhaps more).

You can:
1) Use Ada.Streams.Stream_IO and Ada.Streams.Read (read must be called directly
with the entire buffer).
2) Use Ada.Sequential_IO (it'll have to be instantiated with the whole buffer as
its type).
3) Pragma interface to C and use the same calls you did below (it's a dumb way
to do it rather than the other 2 options, but it works).

>"Sergio" <alguien@microsoft.com> escribi� en el mensaje
>news:n5su6.24687$CL6.767652@telenews.teleline.es...
>> How could I do this in Ada? Could I do it at a reasonable speed? I don't
>> know how, please help me. Thanks
>>
>> void WorkFile(char *fileName)
>> {
>>     char Buffer[4096];
>>     FILE *handle;
>>
>>     handle = fopen(fileName, "r");
>>     while (!feof(handle))
>>     {
>>         fread(handle, 4096, 1, buffer); /* Read data from file to buffer
>*/
>>         Work(Buffer);   /* ... do some work with such data */
>>     }
>> }

If you'd like to see some code I have laying around that does almost exactly
this, just say the word and I'll post it.

About the only thing you can do with C that you can't do with Ada is have a
yearly obfuscated code contest with thousands of worthy submissions. :-)

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



^ permalink raw reply	[relevance 5%]

* Re: text_io is not a predefined library
  @ 2001-03-13 10:47  7%   ` David C. Hoos, Sr.
  0 siblings, 0 replies; 130+ results
From: David C. Hoos, Sr. @ 2001-03-13 10:47 UTC (permalink / raw)


Using Text_IO in place of Ada.TextIO is not the problem.

Note the following from RM95, J.1;
The following library_unit_renaming_declarations exist:

2 with Ada.Unchecked_Conversion;
generic function Unchecked_Conversion renames Ada.Unchecked_Conversion;
3 with Ada.Unchecked_Deallocation;
generic procedure Unchecked_Deallocation renames Ada.Unchecked_Deallocation;
4 with Ada.Sequential_IO;
generic package Sequential_IO renames Ada.Sequential_IO;
5 with Ada.Direct_IO;
generic package Direct_IO renames Ada.Direct_IO;

6 with Ada.Text_IO;
package Text_IO renames Ada.Text_IO;
7 with Ada.IO_Exceptions;
package IO_Exceptions renames Ada.IO_Exceptions;
8 with Ada.Calendar;
package Calendar renames Ada.Calendar;
9 with System.Machine_Code;
package Machine_Code renames System.Machine_Code; -- If supported.

The earlier suggestion by Jeff Creem that it is a GNAT installation
problem is the correct explanation for the phenomenon.

"DuckE" <nospam_steved94@home.com> wrote in message
news:dKhr6.559748$U46.16631404@news1.sttls1.wa.home.com...
> Text_Io is a child of Ada.
>
> Try:
>   with Ada.Text_Io;
>   use Ada.Text_Io;
>
> SteveD
>
> "Andrew Busolin" <abusolin@chariot.net.au> wrote in message
> news:3aad6b31_5@news.chariot.net.au...
> > Hi there,
> >
> > I have written a little hello world program in an effort to test out the
> ada
> > compiler I have recently downloaded. I am able to compile it using
> > gcc -c -gnats -c hello.adb, however when I try to gnatmake it using
> > gnatmake -c hello.adb it returns "ada.text_io" is not a predefined
library
> > unit
> > compilation abandoned!!!
> >
> > Can someone please tell me why this is and how I can fix it!
> >
> > Best Regards
> >
> > Andrew Busolin
> >
> >
> > with Text_Io;
> > use Text_Io;
> >
> > procedure hello is
> > begin
> > Put("hello");
> > end hello;
> >
> >
>
>




^ permalink raw reply	[relevance 7%]

* Optimization Question
@ 2001-01-22  0:05  5% dvdeug
  0 siblings, 0 replies; 130+ results
From: dvdeug @ 2001-01-22  0:05 UTC (permalink / raw)


I'm trying to write a program similar to the Unix utility strings, as my
copy of strings refuses to run a 17GB file. It seems to work, but it's
about 10x slower than strings, and rough calculations puts running time
on that 17GB file at 10 hours. I'm running the woody Debian version of
GNAT (3.13) on i686-linux-gnu, and I compiled the program with gnatmake
-g -gnatwa -gnatpn -Wall -W -O3 strings.adb. Is there anything I've
missed that speed this program a lot? (It's been run through gcov, so
the numbers up front are execution counts.)


		with Ada.Characters.Handling; use Ada.Characters.Handling;
		with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
		with Ada.Sequential_IO;
		with Ada.Command_Line; use Ada.Command_Line;
		with Ada.Text_IO;

           2    procedure Strings is

           1       type Byte is mod 2 ** 8;
		   package Byte_IO is new Ada.Sequential_IO (Byte);
		   use Byte_IO;

       56710       function String_Charp (A : Character) return Boolean
is
		   begin
       56710          return Is_ISO_646 (A) and then
		        (Is_Graphic (A) or else A = HT or else A = LF or else A = CR);
		   end String_Charp;
		   pragma Inline (String_Charp);

           1       Binary_File : File_Type;
           1       Letter_Buffer : String (1 .. 4);
		   subtype Buffer_Size is Integer range 0 .. 4;
           1       Letters_Found : Buffer_Size := 0;
           1       Current_Char : Byte;

           1       Seperating_String : constant String := (LF, NUL);

		begin
           1       if Argument_Count /= 1 then
      ######          Set_Exit_Status (1);
      ######          Ada.Text_IO.Put ("One file name only!");
      ######          return;
		   end if;

           1       Open (Binary_File, In_File, Argument(1));
       56711       loop
       56711          Read (Binary_File, Current_Char);

       56710          if String_Charp (Character'Val (Current_Char))
then
       29610             if Letters_Found < 4 then
        8453                Letters_Found := Letters_Found + 1;
        8453                Letter_Buffer (Letters_Found) :=
Character'Val (Current_Char);
        8453                if Letters_Found = 4 then
         916                   Ada.Text_IO.Put (Letter_Buffer);
		            end if;
		         else
       21157                Ada.Text_IO.Put (Character'Val
(Current_Char));
		         end if;
		      else
       27100             if Letters_Found = 4 then
         916                Ada.Text_IO.Put (Seperating_String);
		         end if;
       27100             Letters_Found := 0;
		      end if;
		   end loop;
      ######       Ada.Text_IO.Put ("Invalid end!");
      ######       Set_Exit_Status (2);
		exception
           1       when End_Error =>
           1          Close (Binary_File);
      ######       when others =>
      ######          raise;
		end Strings;



--
David Starner - dstarner98@aasaa.ofe.org


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[relevance 5%]

* Learn Ada! - Free Ada-Belgium course starts Jan 24
@ 2001-01-21 21:30  1% Dirk Craeynest
  0 siblings, 0 replies; 130+ results
From: Dirk Craeynest @ 2001-01-21 21:30 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 20792 bytes --]

------------------------------------------------------------------------

                       Call for Participation

                             Learn Ada!

                 Ada-Belgium presents a free course

                          January-March 2001
                      U.L.B., Brussels, Belgium

                    Bi-weekly on Wednesday evening
                      Starting January 24, 2001

   http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/local.html

------------------------------------------------------------------------

  Modern society is becoming very dependent upon software. Our
  transport systems, financial systems, medical systems and defense
  systems all depend to a very large degree upon software. As a
  consequence the safety of many human lives and much property now
  depends upon the reliable functioning of software. Moreover, the
  fall in the cost of hardware has now made possible the development
  of large software systems.

  Ada is a programming language of special value in the development
  of large programs which must work reliably. [...] Ada is a modern
  programming language suitable for those application areas which
  benefit from the discipline of organized development, that is,
  Software Engineering; it is a general purpose language with special
  applicability to real-time and embedded systems. [...]

  Although Ada was originally designed to provide a single flexible
  yet portable language for real-time embedded systems to meet the
  needs of the US DoD, its domain of application has expanded to
  include many other areas, such as large-scale information systems,
  distributed systems, scientific computation, and systems
  programming. Furthermore, its user base has expanded to include all
  major defense agencies of the Western world, the whole of the
  aerospace community and increasingly many areas in civil and
  private sectors such as telecommunications, process control and
  monitoring systems. Indeed, the expansion in the civil sector is
  such that civil applications now generate the dominant revenues of
  many vendors.

  (from "Ada 95 Rationale: The Language, The Standard Libraries",
  John Barnes (ed.), Lecture Notes in Computer Science, vol. 1247,
  Springer-Verlag, 1997, ISBN 3-540-63143-7)

Ada-Belgium is a non-profit volunteer organization whose purpose is to
promote the use in Belgium of the Ada programming language, the first
ISO standardized object-oriented language.

Early 2001, Ada-Belgium will run a course teaching Ada 95, at the
premises of the U.L.B. in Brussels, bi-weekly on Wednesday evenings
starting on January 24, 2001.

This is an updated re-run of the highly successful Ada course
organized in the fall of 1998.

------------------------------------------------------------------------

Highlights
----------

  * The course will be modular: you may skip modules discussing
    subjects you already know about without losing the thread of the
    course. The first module will be an introduction to Ada mainly for
    programmers in other languages. After this the modules will be of
    interest to both newcomers to Ada and those already working in Ada
    83 who wish to learn Ada 95.
  * The course will take the form of evening sessions every two weeks.
    There will be small exercises during the evening sessions and
    larger exercises which may be completed between sessions. Ada
    compilers will be available for the completion of these exercises.
  * The course will be taught in English. Everyone interested is
    welcome.

More information is available below and via the Ada Course Home Page
via URL

   http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/local.html

Here you will find info on:
  * the full program,
  * abstracts of the modules,
  * free Ada CD-ROMs for Ada-Belgium members,
  * documentation that will be handed out,
  * the location of the course,
  * registration,
  * the course secretariat, and
  * acknowledgements,
  * a course registration form,
  * an Ada-Belgium membership application form.

This free Ada course is an opportunity not to be missed! Do not delay
to register!

Looking forward to meet many of you in Brussels.

Dirk Craeynest
Ada-Belgium Board
ada-belgium-board@cs.kuleuven.ac.be

------------------------------------------------------------------------

Program
-------

Schedule:

Wed 24 Jan 2001 - Introduction to Ada - part 1
Wed  7 Feb 2001 - Introduction to Ada - part 2

Wed 21 Feb 2001 - Object-Oriented Programming in Ada - part 1
Wed  7 Mar 2001 - Object-Oriented Programming in Ada - part 2

Wed 21 Mar 2001 - Parallel Programming in Ada

Wed 28 Mar 2001 - Distributed Programming in Ada

more sessions might be scheduled.

Note: during the week of 14-18 May, 2001, Ada-Belgium co-organizes
the 6th International Conference on Reliable Software Technologies -
Ada-Europe'2001, in Leuven.

------------------------------------------------------------------------

Abstracts
---------

* "Introduction to Ada"
  Raymond Devillers, U.L.B., Bruxelles
  (replaces Marc Gobin, Royal Military Academy, Brussel)

  (2 sessions; abstract provided by the author)

  The introductory course will cover most of the core language, except
  for the material covered in the subsequent modules, such as object
  oriented features and tasking.
  The course will essentially be taught as a sequence of simple programs
  showing common aspects of programming in Ada.
  We will first walk to the simple predefined types and see how
  declarations are controlled.
  The power of Ada conditional statements and loop statements will be
  illustrated. The introduction of new types and subtypes will be
  explained, including arrays, records and pointers.
  Procedures and functions will than be introduced, first embedded in
  the program itself and than defined outside a program ready to be used
  by as many programs as needed. This means the introduction of packages
  and exceptions.
  The power of generic units will be shown and we will discuss the input
  output possibilities of the predefined packages Ada.Text_Io,
  Ada.Sequential_Io and Ada.Direct_Io.

  References
  - John Barnes: "Programming in Ada95, 2nd edition" (Addison Wesley)
  - Michael Feldman: "Software Construction and Data structures with
    Ada95" (Addison Wesley)
  - Michael Feldman & Koffman: "Ada95, Problem solving and program
    design" (Addison Wesley)
  - Ada 95 Reference Manual (Springer Verlag)
  - Ada 95 Rationale (Springer Verlag)
  - Ada 95 Style Guide (Springer Verlag)


* "Object-Oriented Programming in Ada"
  Luc Bernard, OFFIS nv/sa, Zaventem

  (2 sessions; abstract provided by the author)

  One of the major contributions of the 95 version of the Ada language
  is certainly the way it addresses Object-Oriented Design and
  Development.

  The two sessions will present how OO concepts have been added to the
  language on top of existing ones (types, derivations, etc...). No
  particular knowledge of OO is required to follow these sessions since
  the basic concepts will be briefly presented.


* "Parallel Programming in Ada"
  Raymond Devillers, U.L.B., Bruxelles

  (1 session)

  Many more programmers are having to work in multi-threaded
  environments today: most modern operating systems support threads (or
  light-weight processes) to some extent. The problem with threads is
  that they are not standard and so are not portable. Every operating
  system has a differing set of application programmers' interfaces
  (APIs) and frequently differing scheduling and priority rules. Thread
  programming is also notoriously difficult to manage in C and difficult
  to encapsulate in C++. Neither C nor C++ provides any support for
  important issues in multi-threaded programming features such as
  re-entrant functions and interprocess communication (IPC).

  Unlike C++ Ada defines a model for concurrent programming as part of
  the language itself. Few other languages (Occam and Java are examples)
  provide language level concurrency; other languages (Modula-3) provide
  a concurrency model through the use of standard library abstractions.
  In Ada there are two base components: the task which encapsulates a
  concurrent process, and the protected type, which is a data structure
  that provides guarded access to its data. These features can be used
  to develop responsive, high-performance applications utilizing one of
  the few truly cross-platform models for concurrent processing.

  The real-time systems annex provides additional facilities for
  programming in either a hard or a soft real-time environment. The main
  thrust of this annex is to provide programmers of real-time systems
  with an environment which provides fixed, predictable scheduling of
  tasks and interrupts within an application.

  (from "Ada 95 for C and C++ Programmers", Simon Johnston, Addison
  Wesley Longman, 1997, ISBN 0-201-40363-3)


* "Distributed Programming in Ada"
  Yolande Berbers, K.U.Leuven, Leuven

  (1 session)

  As presented at the Ada-Belgium'97 Seminar on Developing Distributed
  Applications, several different approaches are available. The most
  important ones are using CORBA or the Ada 95 distributed systems annex
  (or both).

  The Ada 95 programming language is a powerful and flexible language
  that provides a safe environment for creating reliable software. The
  OMG Common Object Request Broker Architecture (CORBA) is a flexible
  environment for creating potentially distributed software components.
  The marriage of these two technologies results in a uniquely powerful
  environment for creating high performance, reliable, distributed
  software components.

  (from "Ada-Belgium'97 - Call for Participation", Ada-Belgium, 1997)

  Ada 95 is the first general-purpose language to provide a standard
  distributed programming paradigm. By combining the distributed and
  object-oriented features of Ada 95, it is possible to create an
  application where objects are physically distributed over a network of
  machines, without having to interface to any low-level communication
  layer. Likewise, by combining the distributed and real-time
  capabilities of Ada 95, it is possible to design applications which
  meet real-time constraints in a distributed environment.

  GNAT, and more specifically GLADE (GNAT Library for Ada Distributed
  Execution), is the first commercial implementation of the distributed
  Ada 95 programming model. This implementation allows a distributed
  application to run on a network of heterogeneous machines, to support
  different network protocols, and to provide replication and
  fault-tolerance.

  (from "GLADE - Distributed systems in Ada 95", ACT Europe, 1998)

  Contents of this session:
  - Strategies to program distributed applications
  - Ada 95 distributed system annex overview
  - Categorization pragmas: definitions and examples
  - GNATDIST: Configuration tool and language
  - GARLIC: PCS and its extended services

------------------------------------------------------------------------

Free Ada CD-ROMs for Ada-Belgium members
----------------------------------------

Copies of the full Ada and Software Engineering CD-ROM set (version 1),
provided by Ada-Belgium through an agreement with the Special Interest
Group on Ada of the ACM (ACM SIGAda) and handed out at previous
Seminars, will be freely distributed to direct Ada-Belgium members
attending the course. This CD-ROM set of 4 discs includes a.o. ports to
lots of platforms of the GNU Ada 95 compiler (GNAT), and Aonix' Ada 95
Compiler and Environment for MS Windows. More information on this Ada
and Software Engineering CD-ROM set is available separately.


Documentation
-------------

We plan to provide copies of the presentations at each course session.

In addition, we still have a small number of documentation sets of the
Ada-Belgium'98 Seminar (theme "Concurrency & Real-Time") and the
Ada-Belgium'99 Seminar (theme "Ada 95 Works!") for direct members not
attending these seminars (as availability permits). These sets contain,
a.o., printed proceedings with papers related to the presentations,
copies of slides, and additional documents and papers.

------------------------------------------------------------------------

Location
--------

The following concerns the course modules, not the conference:
  * Place:
    Universit� Libre de Bruxelles (ULB)
    Boulevard du Triomphe
    Campus de la Plaine
    1050 Brussels
  * Room:
    "Salle des Professeurs", building NO, 9th level, room NO.9.06.
  * Time:
    19:00 - 22:00 (including break)

An access plan to the Campus de la Plaine of the U.L.B. is available
via the Ada Course Web-pages.  Parking facilities are at access no. 2
(parking Fraiteur, the closest) or no. 4 (parking UAE, usually has free
space). You can check on-line how to get to Brussels and how to reach
the V.U.B./U.L.B. depending on the means of transport you use.


Registration
------------

Advance registration is prefered. Registration is free of charge.

Please return the attached Registration Form as soon as possible.

As mentioned above, for direct Ada-Belgium members registration
includes the option to receive a free copy of the full 4-disc Ada and
Software Engineering CD-ROM set, containing a.o. several editions of
two Ada 95 compilers: the public GNAT distribution from ACT, for lots
of platforms, and the ObjectAda Special Edition from Aonix, for
Windows 95 and NT.

A limited supply of additional material that was distributed at the
Ada-Belgium'98 and '99 Seminars is also available for direct members
on their request (see above and registration form).

Others registering for (a) course module(s) can optionally become
Ada-Belgium members, and hence also receive the free CD-ROMs and
documentation.


Course Secretariat
------------------

Ada-Belgium Secretariat
Attn. Prof. R. Devillers
c/o Universit� Libre de Bruxelles (U.L.B.)
Boulevard du Triomphe / Triomflaan
Campus de la Plaine, CP 212, B-1050 Brussels
Phone (32)-2-650.56.11, Fax (32)-2-650.56.09
E-mail: ada-belgium-board@cs.kuleuven.ac.be

------------------------------------------------------------------------

                           Acknowledgements

We would like to thank our sponsors for their continued support of our
    activities: ACT Europe, John Robinson & Associates, Katholieke
Universiteit Leuven (K.U.Leuven), Koninklijke Militaire School / Ecole
   Royale Militaire (K.M.S./E.R.M.), OFFIS nv/sa, Rational Software
Corporation, Top Graph'X, and Universit� Libre de Bruxelles (U.L.B.).

------------------------------------------------------------------------

 Information on this and other Ada-Belgium events is available on the
   Internet at the Ada-Belgium World-Wide-Web pages and is updated
                       regularly. Check out URL

   http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/local.html

-- cut here ------- >8 ------- >8 ------- >8 ------- >8 ------- >8 -----

Ada-Belgium Ada Course Registration
________________________________________________________________________

Please mail to                       or fax to
--------------                       ---------
Ada-Belgium Secretariat              + 32 (0)2 650.56.09
c/o Universite' Libre de Bruxelles
Attn. Prof. R. Devillers
Boulevard du Triomphe / Triomflaan   or e-mail to
Campus de la Plaine, CP 212          ------------
B - 1050 Brussels, Belgium           ada-belgium-board@cs.kuleuven.ac.be

Personal Information
--------------------
Name  __________________________   First name  _________________________
Job title / Occupation  ________________________________________________
Company / Institution  _________________________________________________
Address  _______________________________________________________________
________________________________________________________________________
Zip code  ______________________   City  _______________________________
Country  _______________________   E-mail  _____________________________
Telephone  _____________________   Telefax  ____________________________

I want to register, free of charge, for Ada-Belgium's Ada Course
that will take place at the U.L.B. in Brussels, starting early 2001,
bi-weekly on Wednesday evenings 19:00 - 22:00.

I will attend the following sessions:       (Please tick all that apply)
-------------------------------------
___  Wed 24 Jan 2001 - Introduction to Ada - part 1
___  Wed  7 Feb 2001 - Introduction to Ada - part 2
___  Wed 21 Feb 2001 - Object-Oriented Programming in Ada - part 1
___  Wed  7 Mar 2001 - Object-Oriented Programming in Ada - part 2
___  Wed 21 Mar 2001 - Parallel Programming in Ada
___  Wed 28 Mar 2001 - Distributed Programming in Ada
  (more sessions might be scheduled)

Indication of interest (separate registration will be required later):
___   14-18 May 2001 - 6th International Conference on Reliable Software
                       Technologies - Ada-Europe'2001, Leuven, Belgium

Membership Status for 2001                        (Please tick one item)
--------------------------
___  I am an individual Ada-Belgium member
___  I am appointed contact person of a corporate Ada-Belgium member
___  I want to register as Ada-Belgium member
       (please mail or fax an Ada-Belgium membership application form
       and pay the appropriate fee)
___  I am not, nor do I want to register as, Ada-Belgium member
       (and hence am NOT entitled to the free Ada CD-ROMs and
        documention sets)

For Ada-Belgium Members Only                (Please tick all that apply)
----------------------------
___  I would like to receive a copy of the Ada and Software Engineering
       2 CD-ROM base set (November 1998)
___  I would like to receive a copy of the Ada and Software Engineering
       2 CD-ROM update 2 set (October 1999)
___  I would like to receive a copy of the documentation set of the
       Ada-Belgium'99 Seminar, theme "Ada 95 Works!"
       (as availability permits)
___  I would like to receive a copy of the documentation set of the
       Ada-Belgium'98 Seminar, theme "Concurrency & Real-Time"
       (as availability permits)

Signature  _________________________   Date  ___________________________

-- cut here ------- >8 ------- >8 ------- >8 ------- >8 ------- >8 -----

2001 Ada-Belgium Membership Application
________________________________________________________________________

Please mail to                                  or fax to
--------------                                  ---------
Ada-Belgium                                     + 32 (0)2 650 56 09
c/o Universite' Libre de Bruxelles (ULB)
Boulevard du Triomphe
Campus de la Plaine, CP 212
B - 1050 Bruxelles, Belgium                         Page 1 of _______


Personal Information
--------------------
Name  __________________________   First name  _________________________
For Corporate Members: Name of Appointed Contact Person
Job title / Occupation  ________________________________________________
Company / Institution  _________________________________________________
Address  _______________________________________________________________
________________________________________________________________________
Zip code  ______________________   City  _______________________________
Country  _______________________   E-mail  _____________________________
Telephone  _____________________   Telefax  ____________________________

The above address is  ___  my company address
                   ___  my private address

Membership  (Includes Ada-Europe Membership & Benefits Package)
----------                               (Please tick one item)
___  Individual Member  (annual fee:  30 EUR = 1 210 BEF)
___  Corporate Member   (annual fee: 130 EUR = 5 244 BEF)
___  Student Member     (annual fee:  15 EUR =   605 BEF)

Payment information                      (Please tick one item)
-------------------
YES, I agree to pay the appropriate registration fee to Ada-Belgium VZW
___  to account number 979-3829669-17 (Argenta), or
___  to account number 409-9054291-64 (KBC),
mentioning "2001 Ada-Belgium Membership"

Ada-related Points of Interest
------------------------------
If you have any specific point of interest, please mention them in
attachment to this form.

Additional Addresses
--------------------
If you know other people or companies in Belgium who are interested
in Ada, please mention their names and addresses in attachment to
this form, and we will contact them with information on Ada-Belgium.
Thank you.


Signature  _________________________   Date  ___________________________


Attachment  ____________________________________________________________

-- cut here ------- >8 ------- >8 ------- >8 ------- >8 ------- >8 -----



^ permalink raw reply	[relevance 1%]

* Re: File I/O
  @ 2000-09-29  3:15  5% ` tmoran
  0 siblings, 0 replies; 130+ results
From: tmoran @ 2000-09-29  3:15 UTC (permalink / raw)


>How can I read a file and write to a file in Ada?
  What kind of file?

  For text files, consisting of variable length lines separated by CR
or LF, use Ada.Text_IO

  For files consisting of a homogenous series of binary records,
look at Ada.Sequential_IO

  For files consisting of a homogenous set of binary records,  randomly
accessible, look at Ada.Direct_IO

  For files with heterogenous binary stuff, look at Ada.Streams.Stream_IO



^ permalink raw reply	[relevance 5%]

* Re: Reading/writing LPT1
  @ 2000-08-21  0:00  4%     ` Ted Dennison
  0 siblings, 0 replies; 130+ results
From: Ted Dennison @ 2000-08-21  0:00 UTC (permalink / raw)


In article <8nqkbn$dia$1@nyheter.chalmers.se>,
  "David Boman" <e8boman@etek.chalmers.se> wrote:
> I'm running Windows2000 on Intel.

Then you will have to do it the same way a C programmer would do it.
Either open up "LPT1:" as a file and use standard library IO routines
(In our case, probably Ada.Text_IO or Ada.Sequential_IO), or find and
make the corrent calls in Microsoft's Win32 facilities.

> I don't know if Windows2000 allows direct IO, I've heard that
> WinNT/Win2000 is quite strict with this but I'm not sure.

Yes it is. Either you use the Win32 API to change the settings, or you
write and install your own device driver.

Is this something that you are currently doing in Basic on this
platform, or are you trying to change languages and OS'es at the same
time?

If the former, then the easiest thing to do would be to figure out what
Win32 calls your Basic statements get mapped to. If the latter, then you
have really asked a Win2K question, not an Ada question (and thus should
probably take your question to a more appropriate newsgroup).

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[relevance 4%]

* Re: Ada Communications
  @ 2000-01-11  0:00  4% ` Ted Dennison
  0 siblings, 0 replies; 130+ results
From: Ted Dennison @ 2000-01-11  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

In article <947597144.1660.0.nnrp-09.c2de4527@news.demon.co.uk>,
  "TAMS Team" <tamsteam@rolls-royce-rps.demon.co.uk> wrote:
> How do I read and write to a serial port (e.g. COM2) using Ada?  What
> we intend to do is read serial data coming down an RS422 line
> formatted to RS100 protocol, and also transmit back up using the same
> standards.

The flip answer is that you can do it the same way you'd do it in C.
Just call the appropriate system calls.

However, depending on your OS (and perhaps on your compiler) there may
be an even easier way. But, to quote from the Microsoft documentation,
"Serial communications in Microsoft� Win32� is significantly different
from serial communications in 16-bit Microsoft Windows�." DOS is
different yet agian.

If your needs are simple, you may be able to just open the "COM2:" port
using Ada.Sequential_IO. When I had to do this same thing on WinNT, I
used the CreateFile system call to open the port, so that I could set
the parity etc. from my program and use the blocking, non-blocking I/O,
and timed I/O calls.

So what we get down to is that I'm not really sure what your question
is. I've listed below some possiblities, along with their answers:

Q: Do I need system calls to do this?
A: Maybe, it depends on what OS you are using.

Q: Can an Ada program make system calls?
A: Yes.

Q: What system calls do I need to make to do this?
A: That isn't an Ada question, its an OS question. It also depends on
your exact I/O needs (eg: Blocking or non-blocking? Timeouts or no
timeouts? What does your protocol look like?)

Q: How do I make OS calls in Ada?
A: Check your compiler docs. If you are still confused after that, post
your questions here, making sure to mention your compiler and target OS.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[relevance 4%]

* Re: Decoding an octet stream
  1999-11-28  0:00  4% Decoding an octet stream Florian Weimer
@ 1999-11-29  0:00  0% ` David C. Hoos, Sr.
  0 siblings, 0 replies; 130+ results
From: David C. Hoos, Sr. @ 1999-11-29  0:00 UTC (permalink / raw)



Florian Weimer <" "@deneb.cygnus.argh.org> wrote in message
news:877lj2q36g.fsf@deneb.cygnus.argh.org...
> What is the best way to decode an octet stream (i.e. a sequence of
> unsigned eight-bit values) with Ada?  The octet stream consists of
> packet markes (single octets), two-octet integers (stored with the
> most significant octet first), strings (sequences of octets of a given
> length) and so on.  I don't want to use Ada.Sequential_IO, because it
> would mean that only one octet can be read at a time, which seems to
> be quite inefficient.
>
> Streams seem to be nice, though.  If I specify the necessary
> representation clauses, I think I'll only have to write a few 'Read
> and 'Write operations, and composed types will be handled correctly
> almost automatically.  But is this really portable?  Are there any
> targets (except supercomputers, mainframes, and embedded systems)
> where Stream_Element'Size isn't equal to 8?
>
> BTW: I'm currently reading the two-octet integers using a construct like
> `First_Octet * 2**8 + Second_Octet'.  Is it possible to denote the octet
> ordering using a representation clause?  For a target with a matching
> octet order, more efficient code could be generated.

Here's a package I use for just that purpose.  All two- and four-byte
scalar types used in network packets have their 'read and 'write
attributes overridden by instances of these generic procedures.

------------------------------------------------------------------------
-- Byte_Ordering
-- Purpose:
-- Instantiations of the generic procedures provided by This package
-- are Read and Write procedures fully-conformant with the 'Read and
-- 'Write attributes of the type with which the procedure was
-- instantiated.
-- The procedures transform the stream to network order, according to
-- the endianness of the target host.
-- Thus, instantiations of these procedures may be used to override
-- the default stream-oriented attributes of scalar types, so that
-- their stream reads and writes are done in network order,
-- irrespective of host ordering (endianness).
------------------------------------------------------------------------

with Ada.Streams;
package Byte_Ordering is

   generic
      type Item_Type is private;
   procedure Read
     (Stream : access Ada.Streams.Root_Stream_Type'Class;
      Item   :    out Item_type);

   generic
      type Item_Type is private;
   procedure Write
     (Stream : access Ada.Streams.Root_Stream_Type'Class;
      Item   :        Item_type);

end Byte_Ordering;
with System;
package body Byte_Ordering is

   type U8  is mod 2 ** 8;
   for U8'Size use 8;

   type U8_Array   is array (Integer range <>) of U8;

   --=======================
   -- Private subprograms ==
   --=======================

   ----------
   -- Swap --
   ----------

   procedure Swap
     (The_Item : in out U8_Array)
   is
      The_Bytes : array (1 .. The_Item'Size / U8'Size) of U8;
      for The_Bytes'Address use The_Item'Address;
      Temp : U8;
   begin
      for B in 1 .. The_Bytes'Last / 2 loop
         Temp := The_Bytes (B);
         The_Bytes (B) := The_Bytes (The_Bytes'Last - B + 1);
         The_Bytes (The_Bytes'Last - B + 1) := temp;
      end loop;
   end Swap;

   --======================
   -- Public subprograms ==
   --======================

   ----------
   -- Read --
   ----------

   procedure Read
     (Stream : access Ada.Streams.Root_Stream_Type'Class;
      Item   :    out Item_type)
   is
      The_Bytes : U8_Array (1 .. Item'Size / U8'Size);
      for The_Bytes'Address use Item'Address;
      use type System.Bit_Order;
   begin
      U8_Array'Read (Stream, The_Bytes);
      if System.Default_Bit_Order = System.Low_Order_First then
         Swap (The_Bytes);
      end if;
   end Read;

   -----------
   -- Write --
   -----------

   procedure Write
     (Stream : access Ada.Streams.Root_Stream_Type'Class;
      Item   :        Item_Type)
   is
      Item_Copy : Item_type := Item;
      The_Bytes : U8_Array (1 .. Item_Copy'Size / U8'Size);
      for The_Bytes'Address use Item'Address;
      use type System.Bit_Order;
   begin
      if System.Default_Bit_Order = System.Low_Order_First then
         Swap (The_Bytes);
      end if;

      U8_Array'Write (Stream, The_Bytes);
   end Write;

end Byte_Ordering;







^ permalink raw reply	[relevance 0%]

* Decoding an octet stream
@ 1999-11-28  0:00  4% Florian Weimer
  1999-11-29  0:00  0% ` David C. Hoos, Sr.
  0 siblings, 1 reply; 130+ results
From: Florian Weimer @ 1999-11-28  0:00 UTC (permalink / raw)


What is the best way to decode an octet stream (i.e. a sequence of
unsigned eight-bit values) with Ada?  The octet stream consists of
packet markes (single octets), two-octet integers (stored with the
most significant octet first), strings (sequences of octets of a given
length) and so on.  I don't want to use Ada.Sequential_IO, because it
would mean that only one octet can be read at a time, which seems to
be quite inefficient.

Streams seem to be nice, though.  If I specify the necessary
representation clauses, I think I'll only have to write a few 'Read
and 'Write operations, and composed types will be handled correctly
almost automatically.  But is this really portable?  Are there any
targets (except supercomputers, mainframes, and embedded systems)
where Stream_Element'Size isn't equal to 8?

BTW: I'm currently reading the two-octet integers using a construct like
`First_Octet * 2**8 + Second_Octet'.  Is it possible to denote the octet
ordering using a representation clause?  For a target with a matching
octet order, more efficient code could be generated.




^ permalink raw reply	[relevance 4%]

* Re: Binary File Manip. - Possibly a stupid question
  @ 1999-07-20  0:00  4% ` Ted Dennison
  0 siblings, 0 replies; 130+ results
From: Ted Dennison @ 1999-07-20  0:00 UTC (permalink / raw)


In article <3795BF16.BCF418D6@Think.So.Com>,
  Matthew <I.Dont@Think.So.Com> wrote:
> book with no mention of binary files) I came to the conclusion that I
> have to use some kind of Stream (since Stream_IO's End_Of_File
> references the file's size instead of a special character), but I have
> no idea how to use them properly.
>
..
> My compression alg. is currently running on the assumption that the
> stuff read in from the source file can be accessed in 8-bit-byte
chunks
> that can be mapped to character representations.

Streams wil work. However it is best to use them if both the writer and
the eventual reader are using the Ada stream packages. Its possible, if
rather unlikely, that the stream you are using could be playing tricks
on your data (eg: compressing it, reading in bizzarely sized chunks at a
time, byte swapping, etc). You *can* use streams to do this, you just
have to be careful.

If you have an *exact* representation that you want to see on disk
(minus what the file-system does to it, of course), then you should
probably use either Ada.Sequential_IO or Ada.Direct_IO. They are
generics, so you instantiate them with the data type you want to write
to the file.

Another wrinkle to throw on this is that your particular application may
be a good candidate for implemenation *as* a custom stream. :-)

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




^ permalink raw reply	[relevance 4%]

* Re: Dynamic Array Sizing
  @ 1999-06-19  0:00  5% ` jerry
  0 siblings, 0 replies; 130+ results
From: jerry @ 1999-06-19  0:00 UTC (permalink / raw)


Nick Wilson <snow_moose@hotmail.com> wrote:

: I have a file containing an variable amount of data that I want to read
: into an array. My problem is that if I use a dynamic array, eg

: type Array_Store is array (integer range <>) of boolean;

: I have to declare an actual array sometime before reading the values
: into the array, but don't know what size to make the array. I can do two
: passes of the file, one to see the size, then declare the array in a
: block and do another pass to read the values into it.

If you are using GNAT, you could do something like:

--  * notes: - assumes 1-bit booleans
--           - using streams is slower

with GNAT.OS_Lib; use GNAT.OS_Lib;
with Ada.Text_IO; use Ada.Text_IO;

with Ada.Sequential_IO;
with Ada.Unchecked_Deallocation;

procedure Stuff is

   Data_Size_Error : exception;   --  no data in file
   File_Name_Error : exception;   --  file cannot be opened

   type Data_Storage_Type is array (Positive range <>) of Boolean;
   --  an array to store the data in

   type Data_Access is access all Data_Storage_Type;
   --  a pointer to the data

   procedure Free is new
     Ada.Unchecked_Deallocation (Data_Storage_Type, Data_Access);
   --  deallocate a data storage array

   package Boolean_File is new Ada.Sequential_IO (Boolean);
   use Boolean_File;
   --  package for using files of Booleans

   Data         : Data_Access;
   Num_Elements : Positive;
   File_Name    : constant String := "test.dat";

   -----------------------------------
   --  Get number of data elements  --
   -----------------------------------
   function Data_Elements (Path : String) return Positive is
      Fd     : File_Descriptor;
      Size   : Long_Integer;
      C_Name : String := Path & ASCII.NUL;
   begin
      Fd := Open_Read (C_Name'Address, Binary);
      if Fd = Invalid_FD then
         raise File_Name_Error;
      end if;
      Size := File_Length (Fd);
      Close (Fd);
      if Size < 1 then
         raise Data_Size_Error;
      end if;
      return Positive (Size);
   end Data_Elements;

   ------------------------------------------------------------
   --  Create data storage array and return a pointer to it  --
   ------------------------------------------------------------
   function Create_Data_Storage (Elements : Positive) return Data_Access is
      Storage : Data_Access;
   begin
      if Elements < 1 then
         raise Data_Size_Error;
      end if;
      Storage := new Data_Storage_Type (1 .. Elements);
      return Storage;
   end Create_Data_Storage;

   ---------------------------------------
   --  Read data in data storage array  --
   ---------------------------------------
   procedure Load_Data (Path : in String; Data : in Data_Access) is
      File : Boolean_File.File_Type;
   begin
      Open (File, In_File, Path);
      for I in 1 .. Data.all'Length loop
         Read (File, Data(I));
      end loop;
      Close (File);
   end Load_Data;

begin
   Num_Elements := Data_Elements (File_Name);
   Data := Create_Data_Storage (Num_Elements);
   Load_Data (File_Name, Data);
   Put_Line ("Loaded" & Data.all'Length'Img & " Booleans from " & File_Name);
   Free (Data);
end Stuff;

-- 
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[relevance 5%]

* Re: Binary Files in Text Editor
  @ 1998-11-14  0:00  7%       ` Jerry van Dijk
  0 siblings, 0 replies; 130+ results
From: Jerry van Dijk @ 1998-11-14  0:00 UTC (permalink / raw)


robinsoj@my-dejanews.com wrote:

: I have an array of records (there are two string fields, an integer field, and
: a float field) that I converted from a text file to a binary file.  Now I want
: to display those records to the screen like a list.

The problem in the discussion seems to be the persistent use of the term
'binary file'.

For reading/writing records Ada offers several options (Direct_IO,
Sequential_IO and Stream_IO). The easiest is using sequential IO, see
example below.

So, the question is: is something like the example below what you meant,
and why do you need a 'binary file'.

Jerry.

----- records.ads -----------------------------------------------------

package Records is

   type Data_Type is
      record
         Name   : String (1 .. 8);
         Active : Boolean;
         Salary : Float;
      end record;

   File_Name : constant String := "data.dat";

end Records;

----- write.adb -------------------------------------------------------

with Records;
with Ada.Sequential_IO;

procedure Write is

   package Data_Files is new Ada.Sequential_IO (Records.Data_Type);
   use Data_Files;

   File : File_Type;
   Data : array (1 .. 3) of Records.Data_Type;

begin

   Data(1) := ("Jerry   ", True,  120_000.00);
   Data(2) := ("Carolien", True,   40_000.00);
   Data(3) := ("Peter   ", False,  65_000.00);

   Create (File, Out_File, Records.File_Name);
   for I in Data'Range loop
      Write (File, Data(I));
   end loop;
   Close (File);

end Write;

----- read.adb --------------------------------------------------------

with Records;
with Ada.Text_IO;
with Ada.Sequential_IO;

procedure Read is

   package Data_Files is new Ada.Sequential_IO (Records.Data_Type);
   use Data_Files;

   File : File_Type;
   Data : Records.Data_Type;

begin

   Open (File, In_File, Records.File_Name);

   while not End_Of_File (File) loop

      Read (File, Data);

      Ada.Text_IO.Put (Data.Name & ASCII.HT);
      Ada.Text_IO.Put (Boolean'Image (Data.Active) & ASCII.HT);
      Ada.Text_IO.Put (Float'Image (Data.Salary));
      Ada.Text_IO.New_Line;

   end loop;

   Close (File);

end Read;


-- 
-- Jerry van Dijk  | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada
-- Ada & Win32: http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[relevance 7%]

* Learn Ada 95! - Free Ada-Belgium course starts 98/09/23
@ 1998-09-10  0:00  1% Dirk Craeynest
  0 siblings, 0 replies; 130+ results
From: Dirk Craeynest @ 1998-09-10  0:00 UTC (permalink / raw)


------------------------------------------------------------------------

                       Call for Participation 
                                   
                            Learn Ada 95!
                                   
                 Ada-Belgium presents a free course 
                                   
                    Bi-weekly on Wednesday evening
                     Starting September 23, 1998

                      U.L.B., Brussels, Belgium 

   http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/local.html

------------------------------------------------------------------------

  Modern society is becoming very dependent upon software. Our
  transport systems, financial systems, medical systems and defense
  systems all depend to a very large degree upon software. As a
  consequence the safety of many human lives and much property now
  depends upon the reliable functioning of software. Moreover, the
  fall in the cost of hardware has now made possible the development
  of large software systems.
  
  Ada is a programming language of special value in the development
  of large programs which must work reliably. [...] Ada is a modern
  programming language suitable for those application areas which
  benefit from the discipline of organized development, that is,
  Software Engineering; it is a general purpose language with special
  applicability to real-time and embedded systems. [...]
  
  Although Ada was originally designed to provide a single flexible
  yet portable language for real-time embedded systems to meet the
  needs of the US DoD, its domain of application has expanded to
  include many other areas, such as large-scale information systems,
  distributed systems, scientific computation, and systems
  programming. Furthermore, its user base has expanded to include all
  major defense agencies of the Western world, the whole of the
  aerospace community and increasingly many areas in civil and
  private sectors such as telecommunications, process control and
  monitoring systems. Indeed, the expansion in the civil sector is
  such that civil applications now generate the dominant revenues of
  many vendors.
  
  (from "Ada 95 Rationale: The Language, The Standard Libraries",
  John Barnes (ed.), Lecture Notes in Computer Science, vol. 1247,
  Springer-Verlag, 1997, ISBN 3-540-63143-7) 
  

Ada-Belgium is a non-profit volunteer organization whose purpose is to
promote the use in Belgium of the Ada programming language, the first
ISO standardized object-oriented language.

This Fall, Ada-Belgium will run a course teaching Ada 95, at the
premises of the U.L.B. in Brussels, bi-weekly on Wednesday evenings,
starting on September 23, 1998.

------------------------------------------------------------------------

Highlights
----------

  * The course will be modular: you may skip modules discussing
    subjects you already know about without losing the thread of the
    course. The first module will be an introduction to Ada for
    programmers in other languages. After this the modules will be of
    interest to both newcomers to Ada and those already working in Ada
    83 who wish to learn Ada 95.
  * The course will take the form of evening sessions every two weeks.
    There will be small exercises during the evening sessions and
    larger exercises which may be completed between sessions. Ada
    compilers will be available for the completion of these exercises.
  * The course will be taught in English. Everyone interested is
    welcome.
    
More information is available below and at the Ada Course Home Page
via URL

   http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/local.html

Here you will find:
  * the full programme,
  * abstracts of the modules,
  * free Ada CD-ROMs for Ada-Belgium members,
  * documentation that will be handed out,
  * the location of the course,
  * registration,
  * the course secretariat,
  * acknowledgements,
  * a course registration form,
  * an Ada-Belgium membership application form.
    
This free Ada 95 course is an opportunity not to be missed! Do not
delay to register! 

Looking forward to meet many of you in Brussels.

Dirk Craeynest
Ada-Belgium Board
ada@belgium.eu.net

------------------------------------------------------------------------

Programme
---------

Preliminary schedule:

Wed 23 Sep 1998 - Introduction to Ada - part 1
Wed  7 Oct 1998 - Introduction to Ada - part 2

Wed 21 Oct 1998 - Object-Oriented Programming in Ada - part 1
Wed  4 Nov 1998 - Object-Oriented Programming in Ada - part 2

Wed 18 Nov 1998 - Parallel Programming in Ada

Fri  4 Dec 1998 - 8th Annual Ada-Belgium Seminar (tentative)
  (a full day event, with a.o. invited speakers and project
  presentations; theme: parallelism, tasking, real-time, etc.;
  separate registration will be required later)

Wed 16 Dec 1998 - Distributed Programming in Ada

more sessions will be scheduled in 1999

------------------------------------------------------------------------

Abstracts
---------

* "Introduction to Ada"
  Marc Gobin, Royal Military Academy, Brussel
  
  (2 sessions; abstract provided by the author)

  The introductory course will cover most of the core language, except
  for the material covered in the subsequent modules, such as object
  oriented features and tasking.
  The course will essentially be taught as a sequence of simple programs
  showing common aspects of programming in Ada.
  We will first walk to the simple predefined types and see how
  declarations are controlled.
  The power of Ada conditional statements and loop statements will be
  illustrated.  The introduction of new types and subtypes will be
  explained, including arrays, records and pointers.
  Procedures and functions will than be introduced, first embedded in
  the program itself and than defined outside a program ready to be used
  by as many programs as needed.  This means the introduction of
  packages and exceptions.
  The power of generic units will be shown and we will discuss the input
  output possibilities of the predefined packages Ada.Text_Io,
  Ada.Sequential_Io and Ada.Direct_Io.

  References
  - John Barnes: "Programming in Ada95, 2nd edition" (Addison Wesley)
  - Michael Feldman: "Software Construction and Data structures with
    Ada95" (Addison Wesley)
  - Michael Feldman & Koffman: "Ada95, Problem solving and program
    design" (Addison Wesley)
  - Ada 95 Reference Manual (Springer Verlag)
  - Ada 95 Rationale (Springer Verlag)
  - Ada 95 Style Guide (Springer Verlag)
    

* "Object-Oriented Programming in Ada"
  Luc Bernard, OFFIS nv/sa, Zaventem
  
  (2 sessions; abstract provided by the author)

  One of the major contributions of the 95 version of the Ada language
  is certainly the way it addresses Object-Oriented Design and
  Development.

  The two sessions will present how OO concepts have been added to the
  language on top of existing ones (types, derivations, etc...).  No
  particular knowledge of OO is required to follow these sessions since
  the basic concepts will be briefly presented.


* "Parallel Programming in Ada"
  Raymond Devillers, U.L.B., Bruxelles
  
  (1 session)

  Many more programmers are having to work in multi-threaded
  environments today: most modern operating systems support threads (or
  light-weight processes) to some extent.  The problem with threads is
  that they are not standard and so are not portable.  Every operating
  system has a differing set of application programmers' interfaces
  (APIs) and frequently differing scheduling and priority rules.  Thread
  programming is also notoriously difficult to manage in C and difficult
  to encapsulate in C++.  Neither C nor C++ provides any support for
  important issues in multi-threaded programming features such as
  re-entrant functions and interprocess communication (IPC).

  Unlike C++ Ada defines a model for concurrent programming as part of
  the language itself.  Few other languages (Occam and Java are
  examples) provide language level concurrency; other languages
  (Modula-3) provide a concurrency model through the use of standard
  library abstractions.  In Ada there are two base components: the task
  which encapsulates a concurrent process, and the protected type, which
  is a data structure that provides guarded access to its data.  These
  features can be used to develop responsive, high-performance
  applications utilizing one of the few truly cross-platform models for
  concurrent processing.

  The real-time systems annex provides additional facilities for
  programming in either a hard or a soft real-time environment.  The
  main thrust of this annex is to provide programmers of real-time
  systems with an environment which provides fixed, predictable
  scheduling of tasks and interrupts within an application.

  (from "Ada 95 for C and C++ Programmers", Simon Johnston, Addison
  Wesley Longman, 1997, ISBN 0-201-40363-3)


* "Distributed Programming in Ada"
  Yolande Berbers, K.U.Leuven, Leuven
  
  (1 session)

  As presented at the Ada-Belgium'97 Seminar on Developing Distributed
  Applications, several different approaches are available.  The most
  important ones are using CORBA or the Ada 95 distributed systems annex
  (or both).

  The Ada 95 programming language is a powerful and flexible language
  that provides a safe environment for creating reliable software.  The
  OMG Common Object Request Broker Architecture (CORBA) is a flexible
  environment for creating potentially distributed software components.
  The marriage of these two technologies results in a uniquely powerful
  environment for creating high performance, reliable, distributed
  software components.

  (from "Ada-Belgium'97 - Call for Participation", Ada-Belgium, 1997)

  Ada 95 is the first general-purpose language to provide a standard
  distributed programming paradigm.  By combining the distributed and
  object-oriented features of Ada 95, it is possible to create an
  application where objects are physically distributed over a network of
  machines, without having to interface to any low-level communication
  layer.  Likewise, by combining the distributed and real-time
  capabilities of Ada 95, it is possible to design applications which
  meet real-time constraints in a distributed environment.

  GNAT, and more specifically GLADE (GNAT Library for Ada Distributed
  Execution), is the first commercial implementation of the distributed
  Ada 95 programming model.  This implementation allows a distributed
  application to run on a network of heterogeneous machines, to support
  different network protocols, and to provide replication and
  fault-tolerance.

  (from "GLADE - Distributed systems in Ada 95", ACT Europe, 1998)

------------------------------------------------------------------------

Free Ada CD-ROMs for Ada-Belgium members
----------------------------------------

Copies of the April 1998 Edition of the Walnut Creek Ada CD-ROM set,
provided by Ada-Belgium through an agreement with the Special Interest
Group on Ada of the ACM (ACM SIGAda), will be freely distributed to
direct Ada-Belgium members attending the course.  This CD-ROM set
includes a.o.  ports to lots of platforms of the GNU Ada 95 compiler
(GNAT), and Aonix' Ada 95 Compiler and Environment for Windows 95.  More
information on this April 1998 CD-ROM edition is available separately.

We still have a small number of another CD-ROM for those direct
Ada-Belgium members (first-come first-served) that couldn't attend the
Ada-Belgium'97 Seminar end of last year.  CCI (Competence Center
Informatik GmbH) provided copies of the Ada-Tour Version 2.0i CD-ROM
for distribution at the seminar.  This Ada-Tour offers an extensive
introduction to Ada 95 and is targeted to people wanting to find out
more about the language, its foundations and possibilities.  More
information is available on the CCI Web-pages (in German).

Documentation
-------------

We will try to provide copies of the presentations at each course
session.

In addition, we still have a small number of documentation sets of the
Ada-Belgium'97 Seminar on Developing Distributed Applications for direct
members not attending the seminar (as availability permits).  This set
contains, a.o., a printed copy of the CORBA IDL to Ada 95 mapping
document, thanks to the assistance of DG XII at the European Commission,
printed proceedings with papers related to the presentations, copies of
slides, and additional documents and papers.

------------------------------------------------------------------------

Location
--------

The following concerns the course modules, not the seminar:
  * Place:
    Universite' Libre de Bruxelles (ULB)
    Boulevard du Triomphe
    Campus de la Plaine
    1050 Brussels
  * Room:
    "Salle des Professeurs", building NO, 9th level, room NO.9.06.
  * Time:
    19:00 - 22:00 (including break)
    
An access plan to the Campus de la Plaine of the U.L.B. is available
via the Ada Course Web-pages.  Parking facilities are at access no. 2
(parking Fraiteur, the closest) or no. 4 (parking UAE).  You can check
on-line how to get to Brussels and how to reach the V.U.B./U.L.B.
depending on the means of transport you use.


Registration
------------

Advance registration is prefered. Registration is free of charge.

Please return the attached Registration Form as soon as possible.

As mentioned above, for direct Ada-Belgium members registration includes
the option to receive a free copy of the latest edition of the Walnut
Creek double Ada CD-ROM (April 1998), containing a.o. the current
editions of two Ada 95 compilers: the public GNAT distribution from ACT,
for lots of platforms, and the ObjectAda Special Edition from Aonix, for
Windows 95 and NT.

A limited supply of additional material that was distributed at the
Ada-Belgium'97 Seminar is also available fro direct members on their
request (see above and registration form).

Others registering for (a) course module(s) can optionally become
Ada-Belgium members, and hence also receive the free CD-ROMs and
documentation.


Course Secretariat
------------------

Ada-Belgium Secretariat
Attn. Prof. R. Devillers
c/o Universite' Libre de Bruxelles (U.L.B.)
Boulevard du Triomphe / Triomflaan
Campus de la Plaine, CP 212
B-1050 Brussels
Belgium
Phone:  (32)-2-650.56.11
Fax:    (32)-2-650.56.09
E-mail: ada@belgium.eu.net
WWW:    http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/

------------------------------------------------------------------------

                           Acknowledgements
                                   
We would like to thank our sponsors for their continued support of our
activities: John Robinson & Associates, Katholieke Universiteit Leuven
 (K.U.Leuven), Koninklijke Militaire School / Ecole Royale Militaire
 (K.M.S./E.R.M.), OFFIS nv/sa, Rational Software Corporation, Trasys
          nv/sa, and Universite' Libre de Bruxelles (U.L.B.).
                                   
------------------------------------------------------------------------

 Information on this and other Ada-Belgium events is available on the
   Internet at the Ada-Belgium World-Wide-Web pages and is updated
                       regularly. Check out URL
                                   
   http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/local.html

-- cut here ------- >8 ------- >8 ------- >8 ------- >8 ------- >8 -----

Ada-Belgium Ada Course Registration
________________________________________________________________________

Please mail to                                  or fax to
--------------                                  ---------
   Ada-Belgium Secretariat                         + 32 (0)2 650.56.09
   c/o Universite' Libre de Bruxelles (ULB)
   Attn. Prof. R. Devillers                     or e-mail to
   Boulevard du Triomphe / Triomflaan           ------------
   Campus de la Plaine, CP 212
   B - 1050 Brussels, Belgium                      ada@belgium.eu.net

Personal Information
--------------------
Name  __________________________   First name  _________________________
Job title / Occupation  ________________________________________________
Company / Institution  _________________________________________________
Address  _______________________________________________________________
________________________________________________________________________
Zip code  ______________________   City  _______________________________
Country  _______________________   E-mail  _____________________________
Telephone  _____________________   Telefax  ____________________________

I want to register, free of charge, for Ada-Belgium's Ada Course that
will take place at the U.L.B. in Brussels, starting in the fall of 1998,
bi-weekly on Wednesday evenings 19:00 - 22:00.

I will attend the following sessions:       (Please tick all that apply)
-------------------------------------
___  Wed 23 Sep 1998 - Introduction to Ada - part 1
___  Wed  7 Oct 1998 - Introduction to Ada - part 2
___  Wed 21 Oct 1998 - Object-Oriented Programming in Ada - part 1
___  Wed  4 Nov 1998 - Object-Oriented Programming in Ada - part 2
___  Wed 18 Nov 1998 - Parallel Programming in Ada
___  Wed 16 Dec 1998 - Distributed Programming in Ada
     (more sessions will be scheduled in 1999)

Indication of interest (separate registration will be required later):
___  Fri  4 Dec 1998 - 8th Annual Ada-Belgium Seminar (tentative)
       (full day event, theme: parallelism, tasking, real-time, etc.)

Membership Status for 1998                        (Please tick one item)
--------------------------
___  I am an individual Ada-Belgium member
___  I am appointed contact person of a corporate Ada-Belgium member
___  I want to register as Ada-Belgium member
       (please mail or fax an Ada-Belgium membership application form
       and pay the appropriate fee)
___  I am not, nor do I want to register as, Ada-Belgium member
       (and hence am NOT entitled to the free Ada CD-ROMs and
        documention set)

For Ada-Belgium Members Only                (Please tick all that apply)
----------------------------
___  I would like to receive a copy of the Walnut Creek Ada CD-ROM set
       (latest edition, i.e. April 1998)
___  I would like to receive a copy of the documentation set of the
       Ada-Belgium'97 Seminar on Developing Distributed Applications
       (as availability permits)
___  I would like to receive a copy of the Ada-Tour CD-ROM that was
       handed out at the Ada-Belgium'97 Seminar (release 2.0i, as
       availability permits)

Signature  _________________________   Date  ___________________________

-- cut here ------- >8 ------- >8 ------- >8 ------- >8 ------- >8 -----

1998 Ada-Belgium Membership Application
________________________________________________________________________

Please mail to                                  or fax to
--------------                                  ---------
   Ada-Belgium                                     + 32 (0)2 650 56 09
   c/o Universite' Libre de Bruxelles (ULB)
   Boulevard du Triomphe
   Campus de la Plaine, CP 212
   B - 1050 Bruxelles, Belgium                         Page 1 of _______


Personal Information
--------------------
Name  __________________________   First name  _________________________
For Corporate Members: Name of Appointed Contact Person
Job title / Occupation  ________________________________________________
Company / Institution  _________________________________________________
Address  _______________________________________________________________
________________________________________________________________________
Zip code  ______________________   City  _______________________________
Country  _______________________   E-mail  _____________________________
Telephone  _____________________   Telefax  ____________________________

The above address is  ___  my company address
                      ___  my private address

Membership  (Includes Ada-Europe Membership & Benefits Package)
----------                               (Please tick one item)
___  Individual Member  (annual fee: 1 000 BEF)
___  Corporate Member   (annual fee: 5 000 BEF)
___  Student Member     (annual fee:   400 BEF)

Payment information                      (Please tick one item)
-------------------
YES, I agree to pay the appropriate registration fee to Ada-Belgium VZW
___  to account number 979-3829669-17 (Argenta), or
___  to account number 409-9054291-64 (Kredietbank),
     if paying from outside Belgium
mentioning "1998 Ada-Belgium Membership"

Ada-related Points of Interest
------------------------------
If you have any specific point of interest, please mention them in
attachment to this form.

Additional Addresses
--------------------
If you know other people or companies in Belgium who are interested
in Ada, please mention their names and addresses in attachment to
this form, and we will contact them with information on Ada-Belgium.
Thank you.


Signature  _________________________   Date  ___________________________


Attachment  ____________________________________________________________

-- cut here ------- >8 ------- >8 ------- >8 ------- >8 ------- >8 -----




^ permalink raw reply	[relevance 1%]

* Re: [Q]Gnat on Linux
  @ 1998-07-08  0:00  6%   ` grave
  0 siblings, 0 replies; 130+ results
From: grave @ 1998-07-08  0:00 UTC (permalink / raw)
  To: Markus Kuhn

Markus Kuhn wrote:


> Nevertheless, you will also have to look at
> <http://www.gnat.com/chat/2781.html> to handle the next problem that
> you will face after the crt1.o problem is fixed, but then everything
> should be ok.


I've tried the thing explain in http://www.gnat.com/chat/2781.html but
when I execute the shell :
#!/bin/tcsh -f
foreach f (../adainclude/*.ad[bs])
  gcc -c -O2 -gnatpga -I- $f
end

I get for all .ad[bs] this message :
a-sfteio.ads:20:12: "Ada" is not a predefined library unit
compilation abandoned
a-sfwtio.ads:20:12: "Ada" is not a predefined library unit
compilation abandoned
a-siocst.adb:42:31: "Ada.Sequential_Io.C_Streams" is not a predefined
library unit
compilation abandoned
a-siocst.ads:43:26: "Ada.Sequential_Io" is not a predefined library unit
compilation abandoned

I've tried it with the command line and I get the same result :
[xavier@pcu4 adalib]$ gcc -c -gnatpga -I- ../adainclude/a-astaco.adb
a-astaco.adb:40:17: "Ada.Asynchronous_Task_Control" is not a predefined
library unit
compilation abandoned

Do you understand this problem ?

I hope the RedHat 5.1 is not so far from the RedHat 5.0

xavier




^ permalink raw reply	[relevance 6%]

* Re: File IO
       [not found]     <348345B4.6E26@eng.clemson.edu>
@ 1997-12-03  0:00  6% ` Jerry van Dijk
  0 siblings, 0 replies; 130+ results
From: Jerry van Dijk @ 1997-12-03  0:00 UTC (permalink / raw)



In article <348345B4.6E26@eng.clemson.edu> xianchl@eng.clemson.edu writes:

>Does anyone who knows how to use file IO in ada 95? I am learning
>Ada95, and I have tried using Sequential_IO and Direct_IO, but when
>I use read(Input_File, Value), I cannot get the same one as in the
>data file.  If you have some experience on this, would you mind giving
>me some suggestions?  It will be better if you can attach a piece of
>code which works.

It might have been easier if you posted an example and what you expected
it to do, so we might have pointed out the error.

However, since you asked...

   -- File I/O demo

   with Ada.Text_IO;
   with Ada.Sequential_IO;

   procedure File_Demo is

      Data_Size : constant Integer := 5;
      Test_File : constant String  := "test.dat";

      type Data_Array is array (1 .. Data_Size) of Integer;

      package Integer_File is new Ada.Sequential_IO (Data_Array);

      Data_To_Write, Data_Read : Data_Array := (others => 0);

      procedure Write_Data (File_Name : in String;
                            Data      : in Data_Array) is
         My_File : Integer_File.File_Type;
      begin
         Integer_File.Create (File => My_File,
                              Mode => Integer_File.Out_File,
                              Name => File_Name);
         Integer_File.Write  (File => My_File,
                              Item => Data);
         Integer_File.Close  (File => My_File);
      end Write_Data;

      procedure Read_Data (File_Name : in     String;
                           Data      :    out Data_Array) is
         My_File : Integer_File.File_Type;
      begin
         Integer_File.Open  (File => My_File,
                             Mode => Integer_File.In_File,
                             Name => File_Name);
         Integer_File.Read  (File => My_File,
                             Item => Data);
         Integer_File.Close (My_File);
      end Read_Data;

   begin

      Data_To_Write := (1, 2, 3, 5, 8);

      Write_Data (File_Name => Test_File,
                  Data      => Data_To_Write);

      Read_Data  (File_Name => Test_File,
                  Data      => Data_Read);

      if Data_To_Write = Data_Read then
         Ada.Text_IO.Put_Line ("Test succeded!");
      else
         Ada.Text_IO.Put_Line ("Test failed :-(");
      end if;

   end File_Demo;

--

-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




^ permalink raw reply	[relevance 6%]

* Re: File handling
  @ 1997-10-15  0:00  5% ` Matthew Heaney
  0 siblings, 0 replies; 130+ results
From: Matthew Heaney @ 1997-10-15  0:00 UTC (permalink / raw)



In article <343F4BE1.F669CC82@norssi.helsinki.fi>, horn@norssi.helsinki.fi
wrote:

>Is the package Ada.Text_IO only way to handle files?
>Are there procedures like Turbo Pascal's BlockRead and
>BlockWrite in Ada 95?

I haven't done any Turbo Pascal programming in a while, so I'm not sure
what you mean by BlockRead and BlockWrite.  But there are other I/O
pacakges in Ada:

Ada.Sequential_IO
Ada.Direct_IO
Ada.Streams.Stream_IO

One of the strengths of Ada is that, by a very deliberate design choice,
I/O wasn't built into the language (they didn't want to marry the language
to I/O technology that would become obsolete in a few years; see the Ada 83
Rationale for the gory details).  Yes, Ada comes with predefined I/O
packages (the ones listed above), but if these don't meet your needs then
you can just roll your own I/O package that does what you exactly what you
want.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




^ permalink raw reply	[relevance 5%]

* Re: GNAT: Handling of textfile end-of-page
  1997-06-19  0:00  6% ` Anonymous
@ 1997-06-20  0:00  7%   ` Robert Dewar
  0 siblings, 0 replies; 130+ results
From: Robert Dewar @ 1997-06-20  0:00 UTC (permalink / raw)



Jeff Carter says

<<Try instantiating Sequential_Io for type Character:
 
  package Character_Io is new Ada.Sequential_Io (Character);
 
and reading the file with this. You should be able to read the FF
characters OK.>>

A far too heavy Ada 83 solution that is by no means guaranteed to work
in any case, since there is no assurance that sequential IO will use
compatible formats (for example it might pad every record to four characters)

The proper solutoin in Ada 95 is to use Stream_IO.





^ permalink raw reply	[relevance 7%]

* Re: GNAT: Handling of textfile end-of-page
  @ 1997-06-19  0:00  6% ` Anonymous
  1997-06-20  0:00  7%   ` Robert Dewar
  0 siblings, 1 reply; 130+ results
From: Anonymous @ 1997-06-19  0:00 UTC (permalink / raw)



On Wed, 18 Jun 1997 17:40:16 +0200, Jakob Heinemann
<Jakob.Heinemann@ericsson.com> wrote:

> Hi!
> 
> 
> I'm running GNAT 3.09 (gcc 2.72) on a Sun Solaris 2.5.
> I have trouble detecting special characters in a textfile
> that I read.
> 
> In the source text file that I read, pages are separated
> with FF (FormFeed) characters, you know ASCII 12. =
> 
> 
> In the files the FF-character can appear at any place on =
> 
> a line. The Ada.text_io-package can only detect new-page
> as a combination of <new-line><ff> which is not satisfactory
> for me. None of the ways I've tried, reading single characters
> from the file, will return a FF-character. =
> 
> 
> The opposite is on the other hand possible. I can write to
> text files using ada.text_io.put(character'val(12)) and
> it will appear on the outfile anywhere on a line, but then =
> 
> I can't read it back and detect the FF. =
> 
> 
> If anyone can help me with this problem I'll be very happy!
> 
> Please help me! =
> 
> 
>   /Jakob :)
> 
> PS: Please also make a direct reply to my e-mail! =
> 
> 
> mailto:Jakob.Heinemann@ericsson.com
> Ericsson Saab Avionics AB Link=F6ping
> +46 13 284249
> 
> 

Try instantiating Sequential_Io for type Character:

  package Character_Io is new Ada.Sequential_Io (Character);

and reading the file with this. You should be able to read the FF
characters OK.

Jeff Carter  PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"Now go away, or I shall taunt you a second time."
Monty Python & the Holy Grail

Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/

























^ permalink raw reply	[relevance 6%]

* Re: Segmentation Fault
       [not found]     <335358C5.43F8@reading.ac.uk>
@ 1997-04-16  0:00  4% ` William Paul Berriss
  0 siblings, 0 replies; 130+ results
From: William Paul Berriss @ 1997-04-16  0:00 UTC (permalink / raw)



Hi

Here is the Ada code, v simple.

--
-- Filename :    test_memory_allocation.adb
--
-- Programmer :  Will Berriss
--
-- Machine : stssrita (SunOs 5.3,   a.k.a. Solaris 2.3 )
--
-- Compiler : GNAT 3.07 Ada 95 for Solaris 2.3/2.4/2.5
--            (Installed 3 February 1997 by WPB)
--
-- Date :   15 April 1997
--
-- Edited :
--

with Ada.Command_Line, Ada.Sequential_IO, Ada.Text_IO,
Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
--with EEG.Image_IO;

with  EEG.Pixel_Types;             -- For a 512X512 Image type Image,
and type Colour_Pixel
use   EEG.Pixel_Types;             -- and types XCoordinate etc of
Steve's

procedure Test_Memory_Allocation is


   RedMax, GreenMax, BlueMax : Natural := 0;

begin

    Put("Enter No of Red Coordinates  :  ");
    Get(RedMax);
    Put("Enter No of Green Coordinates  :  ");
    Get(GreenMax);
    Put("Enter No of Blue Coordinates  :  ");
    Get(BlueMax);

    New_Line;
    Put("Each bin is a Natural, 4 bytes .");
    New_Line;

    Put("Your Array is of Size : ");
    Put(Natural(RedMax * GreenMax * BlueMax * (Natural'Size / 8)));
    Put("  bytes.");
    New_Line;

    A:declare


      subtype RedRange is Natural range 0 .. RedMax -1;
      subtype GreenRange is Natural range 0 .. GreenMax -1;
      subtype BlueRange is Natural range 0 .. BlueMax -1;


    type Hist_Array is array( RedRange, GreenRange, BlueRange ) of
Natural;

    H : Hist_Array := (others => (others => (others => 0)));

    begin  -- A

      H(1,1,1) := 1;

  end A;

end Test_Memory_Allocation;


Enteriung 85, 85, 85 is fine, but entering 128, 128, 128
causes segmentation fault.

Will
-----
-- 

W P Berriss                 E-mail: W.P.Berriss@reading.ac.uk
Department of Engineering
The University of Reading
Whiteknights
Reading                     Tel:  0118 987 5123 
Berkshire                     (+44 118 987 5123 outside UK)
RG6 6AY    
England                     Fax:  0118 931 3327    

World Wide Web Home Page: 

http://www.elec.rdg.ac.uk/people/postgrads/will.html




^ permalink raw reply	[relevance 4%]

* Re: file locking in Ada
  @ 1997-03-30  0:00  5% ` Nick Roberts
  0 siblings, 0 replies; 130+ results
From: Nick Roberts @ 1997-03-30  0:00 UTC (permalink / raw)




Neil Goodgame <goodganp@aston.ac.uk> wrote in article
<333BB430.BF8@aston.ac.uk>...
> How do perform mutually exclusive file locking in Ada.
> 
> Neil Goodgame(goodganp@aston.ac.uk)

I would suggest that this is an operating-system issue.

Are you going to be using I/O packages supplied with your compiler (such as
Ada.Text_IO, Ada.Sequential_IO, and Ada.Direct_IO, for example), or are you
going to develop your own? 

In the latter case, you will want to check to see what locking facilities
the operating system provides, and make use of them. In the former case,
you will want to check either the supplied documentation, or, failing that
the supplied source code (if it is supplied) to see: (a) whether the I/O
packages automatically do file locking; (b) whether they provide an option
for file locking; and (c) if so, whether it is adequate for your needs.

Nick.





^ permalink raw reply	[relevance 5%]

* Re: CRC in Ada?
  @ 1997-03-19  0:00  6%               ` Robert Dewar
  0 siblings, 0 replies; 130+ results
From: Robert Dewar @ 1997-03-19  0:00 UTC (permalink / raw)



Michael said

<<So yes, I DID feel compelled to use an Ada 83 I/O package. I don't think my
  employer would have much appreciated my spending half a day chasing down
  some C file I/O routines to improve the throughput of my test program.>>

No, you felt compelled to *misuse* an Ada 83 I/O package and write highly
non-portable code that relied on the inner workings of sequential_io in
your particular implementation. OK, if you lacked the knowledge to write
the trivial pragma Import for the appropriate C routine (I assume this
if it would have taken you half a day), then you may have been stuck, and
generating this solution may have been the best you could do.

But it was NOT the right solution in Ada, since it did not meet the spec
of the problem except by accident. You cannot expect to do everything in
Ada. Suppose I tell you to write an Ada program that plays a tune on the
speaker.

You have around a C callable routine called Play_Tune that does exactly
what you want, but instead you write a hairy piece of Ada that uses
address clauses to directly address the memory mapped IO port for the
speaker, and write loops with the right frequencies to play the tune.

Your solution is all Ada. Is it therefore superior? no it is perfectly
horrible, and we assume no one would make such a mistake. But your approach
was a (much less obvious and not nearly so horrible) example of the same
mistake.

The fact of the matter is that there WAS no suitable routine in the Ada 83
IO library to solve your problem, just as there is no Play_Note routine.
When you have this situation, then you use pragma Interface, that is what
it is for!

Now in Ada 95, we have Stream_IO which is suitable for solving your problem,
and comparisons of comaprable code using Stream_IO with corresponding C code
are much more meaningful, but it still may be appropriate to use pragma
Interface.

In London a couple of years ago, I gave a talk "Sleeping with the Enemy",
and the theme was that the attitude that C and C++ and ??? are horrible
languages and that you must never go near them is a counter productive
one for Ada programmers. On the contrary, there is lots of useful stuff
there, and a competent Ada programmer knows when and how to take advantage
of it. Note that of course the C or C++ programmer who has a similar
view of Ada (horrible language, don't want to go near it, don't know,
don't want to know) is similarly hobbling themselves.


<<Certainly not Ada versus C, but definitely
  one compiler versus another compiler.
  Pick your I/O package and your language, and 18 minutes versus 27
  seconds to read
  the same file certainly tells you something. HIS compiler (which happens to be
  C++) has buffered file I/O. MY compiler (which happens to be Ada 83) does not
  buffer file I/O>>.

Nope. That misses the point again, you are not comparing one compiler with
another, but rather two completely different solutions, one using a library
routine appropriate to the job, with another solution using an entirely
inappropriate library routine. It would not surprise me at all if the
difference you see, a factor of 30, has nothing at all to do with buffering,
but rather is a natural consequence of the implementation approach for
sequential_IO, which is undoubtedly written to be reasonable for correct
use of the package, and which may well be slow for this clear misuse.

Just to get a bit of a feel for what I mean by sequential_IO being at
a different level of abstraction from the C getchar, look at the following
little bit of code in GNAT's Ada.Sequential_IO.Read:

      --  For non-definite type or type with discriminants, read size and
      --  raise Program_Error if it is larger than the size of the item.

      if not Element_Type'Definite
        or else Element_Type'Has_Discriminants
      then
         FIO.Read_Buf

Now, given a macro substitution approach to generics, it is likely that
this code is optimized away, but in a shared generic approach, it is 
likely to be a real test, and it is certainly a test that would not 
conceivably be present in the C routine.

Does this mean that sequentio_Io is less efficient than the C routine,
no! It means that they are doing different kinds of things. 

If someone compares the peformance of log in C and sqrt in Ada and
tries to draw conclusions about the efficiency of languages, libraries
or compilers from such a comparison, we would immediately see it as
absurd. Comparing getchar in C with sequential_IO.get in Ada is only
slightly less absurd!





^ permalink raw reply	[relevance 6%]

* Re: CRC in Ada?
  @ 1997-03-09  0:00  6%           ` Dr. John B. Matthews
  0 siblings, 0 replies; 130+ results
From: Dr. John B. Matthews @ 1997-03-09  0:00 UTC (permalink / raw)



In article <dewar.857652688@merv>, dewar@merv.cs.nyu.edu (Robert Dewar) writes:
>   More likely to be efficient is using Read and Write directly on
>   buffers of stream elements.

Yes. In the code below I tried to compare Sequential_IO to Stream_IO
for the two extremes of one-at-a-time vs all-at-once (imagining
a buffered approach to fall between). In the one-at-a-time
procedures, I assumed knowledge of the file's length instead of
calling the relevant End_Of_File predicate; in the all-at-once
procedures, I looped through the resulting buffer.

For Sequential_IO, all-at-once is clearly faster than
one-at-a-time. Stream_IO is more interesting: In Stream_All1,
String'Read is actually slower than looping with Character'Read, as
the former calls Character'Read in a loop, checking for EOF as it
goes. The fastest approach seems to be to read the stream elements
directly, as in Stream_All2.

John
----------------------------------------------------------------
John B. Matthews, M.D.
jmatthews@nova.wright.edu; john_matthews@ccmail.dayton.saic.com
"Whom the gods would destroy, they first invite to program in C"
------------------------------------------------------------------
--|
--| iotest: time IO
--|
--| Author: John B. Matthews, Wright State University
--| Last Modified: March 8, 1997
--|
------------------------------------------------------------------
-- results of 6 runs on a 451239 byte file:
-- ave.     std.dev.
-- 1.00278  0.03391  sequential, one character at a time.
-- 0.72499  0.02679  sequential, entire file.
-- 1.26389  0.01146  stream, one character at a time.
-- 1.41389  0.09738  stream, entire file 1.
-- 0.65113  0.08572  stream, entire file 2.
------------------------------------------------------------------
-- build: gnatmake iotest -largs -Xlstack=500000 (or so)

with Ada.Command_Line;
with Ada.Sequential_IO;
with Ada.Streams.Stream_IO;
with Ada.Text_IO;
with Calendar; use type Calendar.Time;

procedure IOTest is

   package CLI renames Ada.Command_Line;
   package Text_IO renames Ada.Text_IO;
   package Fixed_IO is new Ada.Text_IO.Fixed_IO (Duration);

   Length : Natural;
   Start, Stop : Calendar.Time;
   
   -- Determine the size (in bytes) of the file, Name.
   function File_Size (Name : in String) return Natural is
      package SIO renames Ada.Streams.Stream_IO;
      F : SIO.File_Type;
      Size : Natural;
   begin
      SIO.Open (F, SIO.In_File, Name);
      Size := Integer (SIO.Size(F));
      SIO.Close (F);
      return Size;
   end File_Size;

   procedure Sequential_One (Name : String; Length : Natural) is
      package SIO is new Ada.Sequential_IO (Character);
      F : SIO.File_Type;
      C : Character;
   begin
      SIO.Open (F, SIO.In_File, Name);
      for i in 1 .. Length loop
         SIO.Read (F, C);
      end loop;
      SIO.Close (F);
   end Sequential_One;

   procedure Sequential_All (Name : String; Length : Natural) is
      subtype Data is String (1 .. Length);
      package SIO is new Ada.Sequential_IO (Data);
      F : SIO.File_Type;
      S : Data;
      C : Character;
   begin
      SIO.Open (F, SIO.In_File, Name);
      SIO.Read (F, S);
      for i in 1 .. Length loop
          C := S (i);
      end loop;
      SIO.Close (F);
   end Sequential_All;

   procedure Stream_One (Name : String; Length : Natural) is
      package SIO renames Ada.Streams.Stream_IO;
      F : SIO.File_Type;
      S : SIO.Stream_Access;
      C : Character;
   begin
      SIO.Open (F, SIO.In_File, Name);
      S := SIO.Stream (F);
      for i in 1 .. Length loop
         Character'Read (S, C);
      end loop;
      SIO.Close (F);
   end Stream_One;

   procedure Stream_All1 (Name : String; Length : Natural) is
      subtype Data is String (1 .. Length);
      package SIO renames Ada.Streams.Stream_IO;
      F : SIO.File_Type;
      S : Data;
      C : Character;
   begin
      SIO.Open (F, SIO.In_File, Name);
      Data'Read (SIO.Stream (F), S);
      for i in 1 .. Length loop
          C := S (i);
      end loop;
      SIO.Close (F);
   end Stream_All1;

   procedure Stream_All2 (Name : String; Length : Natural) is
      subtype Data is String (1 .. Length);
      package SIO renames Ada.Streams.Stream_IO;
      F : SIO.File_Type;
      S : Ada.Streams.Stream_Element_Array
             (1 .. Ada.Streams.Stream_Element_Offset(Length));
      L : Ada.Streams.Stream_Element_Offset;
      C : Ada.Streams.Stream_Element;
   begin
      SIO.Open (F, SIO.In_File, Name);
      SIO.Read (F, S, L);
      for i in 1 .. L loop
          C := S (i);
      end loop;
      SIO.Close (F);
   end Stream_All2;

begin

   if CLI.Argument_Count = 1 then
   
      Length := File_Size (CLI.Argument (1));

      Start := Calendar.Clock;
      Sequential_One (CLI.Argument (1), Length);
      Stop := Calendar.Clock;
      Fixed_IO.Put (Stop - Start, 0, 5);
      Text_IO.Put_Line (" sequential, one character at a time.");

      Start := Calendar.Clock;
      Sequential_All (CLI.Argument (1), Length);
      Stop := Calendar.Clock;
      Fixed_IO.Put (Stop - Start, 0, 5);
      Text_IO.Put_Line (" sequential, entire file." );

      Start := Calendar.Clock;
      Stream_One (CLI.Argument (1), Length);
      Stop := Calendar.Clock;
      Fixed_IO.Put (Stop - Start, 0, 5);
      Text_IO.Put_Line (" stream, one character at a time.");

      Start := Calendar.Clock;
      Stream_All1 (CLI.Argument (1), Length);
      Stop := Calendar.Clock;
      Fixed_IO.Put (Stop - Start, 0, 5);
      Text_IO.Put_Line (" stream, entire file 1.");

      Start := Calendar.Clock;
      Stream_All2 (CLI.Argument (1), Length);
      Stop := Calendar.Clock;
      Fixed_IO.Put (Stop - Start, 0, 5);
      Text_IO.Put_Line (" stream, entire file 2.");

   else
      Text_IO.Put_Line ("Usage: iotest <filename>");
   end if;

end IOTest;





^ permalink raw reply	[relevance 6%]

* Re: CRC in Ada?
      @ 1997-03-05  0:00  4% ` David C. Hoos, Sr.
  2 siblings, 0 replies; 130+ results
From: David C. Hoos, Sr. @ 1997-03-05  0:00 UTC (permalink / raw)



This is a multi-part message in MIME format.

------=_NextPart_000_01BC292F.C954A260
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Here is an implementation of a 16-bit CRC in both C and Ada.  The C code is
perhaps ten years old, and is from an implementation of Xmodem.  The Ada
code was translated from that.

The test driver tests both the  C code (as an imported set of functions),
and the Ada code.

The form of the test driver is not suitable for performance testing, as the
CRC generation is swamped by the file reads.  I'd like to modify this in
the next couple of days so as to be able to compare the speeds of the two
implementations.  The test driver does serve to demonstrate the equivalence
of the two implementations, though.

The generating polynomial is one frequently used (x1021), but the value can
be changed as one likes.

-- 
David C. Hoos, Sr.,
http://www.dbhwww.com
http://www.ada95.com

Dr. John B. Matthews <jmatthews@nova.wright.edu> wrote in article
<1997Mar2.220652@nova.wright.edu>...
> Hi! Can anyone point me to 16-bit CRC code in Ada? I've checked the
> PAL and several other archives without luck. Any help appreciated.
> 
> Thanks,
> 
> John
> ----------------------------------------------------------------
> John B. Matthews, M.D.
> jmatthews@nova.wright.edu; john_matthews@ccmail.dayton.saic.com
> "Whom the gods would destroy, they first invite to program in C"
> 
> 
------=_NextPart_000_01BC292F.C954A260
Content-Type: application/octet-stream; name="crc.c"
Content-Transfer-Encoding: 7bit
Content-Description: crc.c (C source code file)
Content-Disposition: attachment; filename="crc.c"

/* crc.c */

#include "crc.h"

#define POLY 0x1021

static unsigned short CRCtable[256];

/* calculate CRC table entry */

unsigned short CalcTable(data,genpoly,accum)
unsigned short data;
unsigned short genpoly;
unsigned short accum;
{static int i;
 data <<= 8;
 for(i=8;i>0;i--)
         {
          if((data^accum) & 0x8000) accum = (accum << 1) ^ genpoly;
          else accum <<= 1;
          data <<= 1;
         }
 return(accum);
}

/* initialize CRC table */

void InitCRC(void)
{int i;
 for(i=0;i<256;i++) CRCtable[i] = CalcTable(i,POLY,0);
}

/* compute updated CRC */

unsigned short UpdateCRC(crc,byte)
unsigned short crc;
unsigned char  byte;
{
 return( (crc << 8) ^ CRCtable[ (crc >> 8) ^ byte ] );
}

------=_NextPart_000_01BC292F.C954A260
Content-Type: application/octet-stream; name="crc.h"
Content-Transfer-Encoding: 7bit
Content-Description: crc.h (C Header File)
Content-Disposition: attachment; filename="crc.h"

void InitCRC(void);
unsigned short UpdateCRC(unsigned short,unsigned char);

------=_NextPart_000_01BC292F.C954A260
Content-Type: application/octet-stream; name="crc_pkg.adb"
Content-Transfer-Encoding: 7bit
Content-Description: crc_pkg.adb (ObjectAda File)
Content-Disposition: attachment; filename="crc_pkg.adb"

package body CRC_pkg is
  type Lookup_Table_Type is
    array (Interfaces.Unsigned_8) of Interfaces.Unsigned_16;
  Lookup_Table : Lookup_Table_Type;
  procedure Update
      (The_CRC_Value : in out Interfaces.Unsigned_16;
       With_The_Byte : in     Interfaces.Unsigned_8) is
    use Interfaces;
  begin
    The_CRC_Value := Shift_Left 
	     (Value  => The_CRC_Value,
	      Amount => 8) xor Lookup_Table 
	(Interfaces.Unsigned_8 (Shift_Right
	 (Value  => The_CRC_Value,
	  Amount => 8)) xor With_The_Byte);
  end Update;

begin -- CRC package initialization
  declare
    function Lookup_Table_Entry
	(For_The_Index      : in Interfaces.Unsigned_8;
	 And_The_Polynomial : in Interfaces.Unsigned_16)
	 return Interfaces.Unsigned_16 is
      use Interfaces;
      Temporary_Data        : Interfaces.Unsigned_16 := Shift_Left
	  (Value  => Interfaces.Unsigned_16 (For_The_Index),
	   Amount => 8);
      Temporary_Accumulator : Interfaces.Unsigned_16 := 0; 
    begin
      for I in reverse 1 .. 8 loop
	if ((Temporary_Data xor Temporary_Accumulator) and 
	    16#8000#) > 0 then
	  Temporary_Accumulator := Shift_Left 
	      (Value => Temporary_Accumulator, 
	       Amount => 1) xor And_The_Polynomial;
	else
	  Temporary_Accumulator := Shift_Left
	      (Value  => Temporary_Accumulator,
	       Amount => 1);
	end if;
	Temporary_Data := Shift_Left
	    (Value  => Temporary_Data,
	     Amount => 1);
      end loop;
      return Temporary_Accumulator;
    end Lookup_Table_Entry;
  begin
    for I in Lookup_Table'Range loop
      Lookup_Table (I) := Lookup_Table_Entry 
	  (For_The_Index => I,
	   And_The_Polynomial => Polynomial);
    end loop;
  end;
end CRC_pkg;


------=_NextPart_000_01BC292F.C954A260
Content-Type: application/octet-stream; name="crc_pkg.ads"
Content-Transfer-Encoding: 7bit
Content-Description: crc_pkg.ads (ObjectAda File)
Content-Disposition: attachment; filename="crc_pkg.ads"

with Interfaces;

package CRC_pkg is

  use type Interfaces.Unsigned_8;
  use type Interfaces.Unsigned_16;
  Polynomial : constant Interfaces.Unsigned_16 := 16#1021#;

  procedure Update
      (The_CRC_Value : in out Interfaces.Unsigned_16;
       With_The_Byte : in     Interfaces.Unsigned_8);

end CRC_pkg;

------=_NextPart_000_01BC292F.C954A260
Content-Type: application/octet-stream; name="test_crc.adb"
Content-Transfer-Encoding: quoted-printable
Content-Description: test_crc.adb (ObjectAda File)
Content-Disposition: attachment; filename="test_crc.adb"

with Ada.Command_Line;
with Ada.Sequential_IO;
with Ada.Text_IO;
with CRC_pkg;
with Interfaces.C;
procedure Test_CRC is
  package C renames Interfaces.C;
  package Command_Line renames Ada.Command_Line;
  package Text_IO renames Ada.Text_IO;
  use type C.Unsigned_Char;
  use type C.Unsigned_Short;
  procedure Init_CRC;
  function Updated_CRC=20
      (Previous_CRC_Accumulation : C.Unsigned_Short;
       Current_Byte		 : C.Unsigned_char)
       return C.Unsigned_Short;
  pragma Import (C, Init_CRC, "InitCRC");
  pragma Import (C, Updated_CRC, "UpdateCRC");
  pragma Linker_Options ("crc.o");
  Current_CRC_Accumulation : C.Unsigned_Short;
  package Unsigned_Short_IO is new Ada.Text_IO.Modular_IO =
(C.Unsigned_Short);
  package Unsigned_Char_IO is new Ada.Sequential_IO (C.Unsigned_Char);
  The_File : Unsigned_Char_IO.File_Type;
  The_Unsigned_Char : C.Unsigned_Char;
begin
  Text_Io.Put_Line (Integer'Image (C.Unsigned_Char'Size));
  Text_Io.Put_Line ("16-bit CRCs (x1021) by file:");
  Text_Io.Put_Line ("(Using imported C subprograms)");
  Init_CRC;
  for F in 1 .. Command_Line.Argument_Count loop
    Text_IO.Put=20
	("File """ &
	 Command_Line.Argument (F));
    begin
      Unsigned_Char_IO.Open
	  (File =3D> The_File,
	   Name =3D> Command_Line.Argument (F),
	   Mode =3D> Unsigned_Char_IO.In_File);
    exception
       when Text_Io.Name_Error =3D>
	 Text_IO.Put_Line (""": -- NOT FOUND!");
    end;
    if Unsigned_Char_IO.Is_Open (The_File) then
      Current_CRC_Accumulation :=3D 0;
      while not Unsigned_Char_IO.End_Of_File (The_File) loop
	Unsigned_Char_IO.Read=20
	    (Item =3D> The_Unsigned_Char,
	     File =3D> The_File);
	Current_CRC_Accumulation :=3D Updated_CRC
	    (Previous_CRC_Accumulation =3D> Current_CRC_Accumulation,
	     Current_Byte              =3D> The_Unsigned_Char);
      end loop;
      Unsigned_Char_IO.Close (The_File);
      Text_IO.Put (""":");
      Unsigned_Short_IO.Put
	  (Item  =3D> Current_CRC_Accumulation,
	   Width =3D> 10,
	   Base  =3D> 16);
      Text_IO.New_Line;
    end if;
  end loop;
 =20
  Text_Io.Put_Line ("(Using Ada subprogram)");
  for F in 1 .. Command_Line.Argument_Count loop
    Text_IO.Put=20
	("File """ &
	 Command_Line.Argument (F));
    begin
      Unsigned_Char_IO.Open
	  (File =3D> The_File,
	   Name =3D> Command_Line.Argument (F),
	   Mode =3D> Unsigned_Char_IO.In_File);
    exception
       when Text_Io.Name_Error =3D>
	 Text_IO.Put_Line (""": -- NOT FOUND!");
    end;
    if Unsigned_Char_IO.Is_Open (The_File) then
      Current_CRC_Accumulation :=3D 0;
      while not Unsigned_Char_IO.End_Of_File (The_File) loop
	Unsigned_Char_IO.Read=20
	    (Item =3D> The_Unsigned_Char,
	     File =3D> The_File);
	CRC_Pkg.Update
	    (The_Crc_Value =3D> Interfaces.Unsigned_16 =
(Current_CRC_Accumulation),
	     With_The_Byte =3D> Interfaces.Unsigned_8 (The_Unsigned_Char));
      end loop;
      Unsigned_Char_IO.Close (The_File);
      Text_IO.Put (""":");
      Unsigned_Short_IO.Put
	  (Item  =3D> Current_CRC_Accumulation,
	   Width =3D> 10,
	   Base  =3D> 16);
      Text_IO.New_Line;
    end if;
  end loop;
 =20
end Test_CRC;

------=_NextPart_000_01BC292F.C954A260--





^ permalink raw reply	[relevance 4%]

* Reading sequential data from Ada.Text_Io.Standard_Input?
@ 1996-07-09  0:00  6% David J. Fiander
  1996-07-09  0:00  0% ` Michael Paus
  1996-07-09  0:00  6% ` Robert Dewar
  0 siblings, 2 replies; 130+ results
From: David J. Fiander @ 1996-07-09  0:00 UTC (permalink / raw)



So, I want to read from standard input, using Ada.Sequential_Io.
I've got

	declare
	    type Byte is mod 256; for Byte'Size use 8;
	    package Byte_Io is new package Ada.Sequential_Io(Byte);

	    Ch: Byte;
	begin
	    Byte_Io.Read(Text_Io.Standard_Input, Ch);
	    -- process the byte;
	end;

which clearly doesn't work, since Text_Io.Standard_Input is most
definitely not a Byte_Io.File_Type.  So I try

	Byte_Io.Read(Byte_Io.File_Type(Text_Io.Standard_Input), Ch);

at which Gnat reports "ambiguous operand", since Standard_Input
is either a Text_Io.File_Type or a Text_Io.File_Access and Gnat
can't figure out which I want.  So I try

	Byte_Io.Read(Byte_Io.File_Type(Text_Io.File_Type'(Text_Io.Standard_Input)), Ch);

which is certainly a mouthful, but also doesn't work.  Gnat
reports

	invalid conversion, not compatible with private type
		"Ada.Text_Io.File_Type" 

thereby informing me that, now that it knows what I want to do,
it's decided that I can't get there from here.

So, what, if anything, is the magic incantation to read raw data
from standard input?

- David




^ permalink raw reply	[relevance 6%]

* Re: Reading sequential data from Ada.Text_Io.Standard_Input?
  1996-07-09  0:00  6% Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
  1996-07-09  0:00  0% ` Michael Paus
@ 1996-07-09  0:00  6% ` Robert Dewar
  1 sibling, 0 replies; 130+ results
From: Robert Dewar @ 1996-07-09  0:00 UTC (permalink / raw)



David asks how to read raw data from standard input. The answer is to
use Stream_IO, it's all setup for that.

You could also create an appropriate sequential_io descriptor, have a look
at package

package Ada.Sequential_IO.C_Streams is

in file s-siocst.ads, which permits opening a sequent file given a C
stream identifier (there are analogous packages for all the I/O packages
in GNAT).

You certainly cannot expect success following the line you were trying.
File types are completely different for different I/O packages, and here
there is no reason to think you could convert one to another. GNAT does
not "know what you want to do", as far as it is concerned you are trying
a totally junk type conversion from one type to a completely unrelated
type that makes no sense at all. 






^ permalink raw reply	[relevance 6%]

* Re: Reading sequential data from Ada.Text_Io.Standard_Input?
  1996-07-09  0:00  6% Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
@ 1996-07-09  0:00  0% ` Michael Paus
  1996-07-09  0:00  6% ` Robert Dewar
  1 sibling, 0 replies; 130+ results
From: Michael Paus @ 1996-07-09  0:00 UTC (permalink / raw)



davidf@worf.mks.com (David J. Fiander) wrote:
> So, I want to read from standard input, using Ada.Sequential_Io.
> 
[...]
> So, what, if anything, is the magic incantation to read raw data
> from standard input?

The key to this kind of problem is to use the new Ada 95 streams
facility. Have a look at "A.12 Stream Input-Output". You can get
a stream access value which is associated with Standard_Input with
a declaration like this:

  S  : Ada.Text_IO.Text_Streams.Stream_Access
       := Ada.Text_IO.Text_Streams.Stream(Ada.Text_IO.Standard_Input);

You will need to with 
Ada.Text_IO, Ada.Text_IO.Text_Streams and Ada.Streams.Stream_IO
in order to get that working.

Have fun

Michael

PS: If you are interested I can send you a little example with a writer
application which writes a data structure to a stream which is
associated with standard output and a reader application which recreates
this data structure from a stream which is connected to standard input.
On UNIX you might then execute these apps like

> writer | reader

which means that the data produced by writer is piped into reader.

-- 
------------------------------------------------------------------------
--Dipl.-Ing. Michael Paus   (Member: Team Ada)
--University of Stuttgart, Inst. of Flight Mechanics and Flight Control
--Forststrasse 86, 70176 Stuttgart, Germany
--Phone: (+49) 711-121-1434  FAX: (+49) 711-634856
--Email: Michael.Paus@ifr.luftfahrt.uni-stuttgart.de (NeXT-Mail welcome)





^ permalink raw reply	[relevance 0%]

* Re: C/C++ ... out of Ada
  @ 1996-02-23  0:00  6%                     ` Richard A. O'Keefe
  0 siblings, 0 replies; 130+ results
From: Richard A. O'Keefe @ 1996-02-23  0:00 UTC (permalink / raw)


ncohen@watson.ibm.com (Norman H. Cohen) writes:

>In article <4ggt07$7mm@goanna.cs.rmit.EDU.AU>, ok@goanna.cs.rmit.EDU.AU
>(Richard A. O'Keefe) writes: 

>|> PL/I-style "record" I/O is also not supported by Ada 95.

>Sequential_IO provides the basic capabilities of PL/I record I/O,
>although it is obviously not a clone of that facility.

I think it would be considerably more accurate to say that Sequential_IO
provides the basic capability of Pascal I/O.  Most of the interesting bits
in PL/I are missing, and sometimes they can be useful.

Package Ada.Sequential_IO takes Element_Type(<>) as generic parameter,
and provides

	File_Type, File_Mode, Create, Open, Close, Delete, Reset,
	Mode, Name, Form, Is_Open, a bunch of exceptions, and

	Read(File, Item), Write(File, Item)

as the only transfer operations.  Now, when I use fread() in UNIX, the data
are transferred from disc to OS buffers, from OS buffers to a stdio buffer,
and thence to my object (2 memory-memory copies), and when I use fwrite()
the same happens.

One of the key features of PL/I record I/O was "locate mode"

Let's see how something like that could be specified in Ada.

	Read_Locate(File, Location)
	-- return access to a record
	Read_Release(File, Location)
	-- releases the record area for re-use

	Write_Locate(File, Location)
	-- return access to a writable record
	Write_Release(File, Location)
	-- releases the record for output

so

	generic

	    type Element_Type(<>) is private;
	    Record_Areas: Positive := 1;

	package Locate_Mode_IO is

	    type Input_Element_Location is access constant Element_Type;
	    type Output_Element_Location is access Element_Type;

	    type File_Type is limited private;
	    type File_Mode is (In_File, In_Out_File, Out_File, Append_File);

	    Open, Close, Delete, Reset, Mode, Name, Form, Is_Open,
	    and End_Of_File declared as in Sequential_IO.

	    exception Record_Areas_Exhausted;
	    -- the generic parameter Record_Areas says how many record
	    -- area pointers can be in client hands for a single file.
	    -- E.g. if Record_Areas = 2, then
	    --	Read_Locate(F, X1);	-- ok
	    --	Read_Locate(F, X2);	-- ok
	    --	Read_Locate(F, X3);	-- Record_Areas_Exhausted

	    exception Released_To_Wrong_File;
	    -- In a call to Read_Release(F, L), the value of L must have
	    -- been obtained by a call to Read_Locate(F, L) with the same
	    -- parameters.  Ditto for Write_Release/Write_Locate; 

	    procedure Read_Locate  (File: in File_Type;
				    Area: out Input_Element_Location);
	    -- if not at end of file, reads a record into a record area
	    -- and sets Area to point to that record area.

	    procedure Read_Release (File: in File_Type;
				    Area: in out Input_Element_Location);
	    -- returns the Area to the File's control, sets Area to null.

	    procedure Write_Locate (File: in File_Type;
				    Area: out Output_Element_Location);
	    procedure Write_Release(File: in File_Type;
				    Area: in out Output_Element_Location);

	end Locate_Mode_IO;

Here's how it would be used:

	with Locate_Mode_IO;

	procdure Main is
	    type Foo_Bar is record ... end record;

	    package Foo_Bar_IO is new Locate_Mode_IO(
		Element_Type => Foo_Bar, Record_Areas => 10);

	    use Foo_Bar_IO;

	    Source: File_Type;
	    Source_Ptr: Input_Element_Location;

	    Destination: File_Type;
	    Destination_Ptr: Output_Element_Location;

	begin
	    Open(Source, In_File, "foobar.dat");
	    Create(Destination, Out_File, "foobar.cpy");
	    while not End_Of_File(Source) loop
		Read_Locate(Source, Source_Ptr);
		Write_Locate(Destination, Destination_Ptr);
		Destination_Ptr.all := Source_Ptr.all;
		Read_Release(Source, Source_Ptr);
		Write_Release(Destination, Destination_Ptr);
	    end loop;
	    Close(Source);
	    Close(Destination);
	end Main;

What's the point of this?  Well, in a typical implementation of Sequential_IO,

    read a record:
	disc -> OS buffer -> file buffer -> internal variable
    write a record
	internal variable -> file buffer -> OS buffer -> disc

That's FOUR memory->memory transfers.  With locate mode IO,

    read a record:
	disc -> OS buffer -> file buffer 1
    copy the record
	file buffer 1 -> file buffer 2
    write a record
	file buffer 2 -> OS buffer -> disc

That's THREE memory->memory transfers.  Copying is about the worst case:
if you are just reading or just writing a file, you cut out half of the
memory transfers,

Then there's the matter of "rewrite".

>|> It might actually be worth discussing this at some time; what did DEC Ada
>|> do about RMS?

>DEC adopted a gcc-based Ada compiler for the Alpha.

That doesn't answer the question at all.  I'm not asking about what
_compiler_ they use, I'm asking "what do they do about interfacing to
and exploiting Open VMS facilities".

>(I presume that by RMS you mean Richard M. Stallman. ;-) )

I presume that Norman Cohen knows what I really meant, but for the benefit
of readers who don't, I meant "Record Management Services".



Look, I'm not an Ada basher.  I love Ada.  Ada does not try to do everything.
There is nothing in the Ada 95 standard that says someone _can't_ write a
package like the one I outlined above.  Indeed, Ada + POSIX binding provides
a firm basis for writing and experimenting with alternative IO models.  (I'd
better save this message and see if any student is interested in doing it
for a project.)  

-- 
Election time; but how to get Labor _out_ without letting Liberal _in_?
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.




^ permalink raw reply	[relevance 6%]

* Re: ada.sequential_io problem
  1995-03-14  6:44 13% ada.sequential_io problem Tore Joergensen
  1995-03-14 14:01  7% ` Robert A Duff
@ 1995-03-15 11:00  6% ` Pascal OBRY
  1 sibling, 0 replies; 130+ results
From: Pascal OBRY @ 1995-03-15 11:00 UTC (permalink / raw)



It's a know bug.

The README at cs.nyu.edu say :

-------------------------------------------------
Sequential_IO Note: Feb 16, 1995 :15:50 EST
 
   In GNAT 2.03 all instantiations of sequential_io will get the message:
   a-sequio.adb:33:59: actual for "Element_Type" must be a definite subtype
 
   The workaround is simple. Modify the type declaration of Element_Type on
   line 22 of adainclude/a-sequio.ads and remove the (<>). This should solve
   the problem.
 
   Note : This is a glitch in our current implementation of Sequential_IO,
   which will be fixed ASAP. In the meantime, the proposed workaround
   restricts one to instantiate Sequential_IO only with constrained types.
-------------------------------------------------
 
--

--|---------------------------------------------------------------
--| Pascal OBRY			e-mail: pascal.obry@der.edf.fr   |
--| EDF-DER-IPN-SID-ISI					         |
--| Bureau G1-010			voice: +33-1-47.65.50.91 |
--| 1 Av General de Gaulle				         |
--| 92141 Clamart CEDEX		     			         |
--| FRANCE			     			         |
--|---------------------------------------------------------------



^ permalink raw reply	[relevance 6%]

* Re: ada.sequential_io problem
  1995-03-14  6:44 13% ada.sequential_io problem Tore Joergensen
@ 1995-03-14 14:01  7% ` Robert A Duff
  1995-03-15 11:00  6% ` Pascal OBRY
  1 sibling, 0 replies; 130+ results
From: Robert A Duff @ 1995-03-14 14:01 UTC (permalink / raw)


In article <3k3e12$2op@toads.pgh.pa.us>,
Tore Joergensen <tore@lis.pitt.edu> wrote:
>What is wrong???

Sounds like a compiler bug.

First of all, Sequential_IO allows both definite and indefinite subtypes
-- that's what the (<>) means.

Furthermore, all elementary subtypes, including modular ones, are
definite.  It's only composite subtypes that can be indefinite.

>I tried to define:
>  package bio is new ada.sequential_io(unsigned_8);
>
>Unsigned_8 is defined in the package interfaces as:
>  type unsigned_8 is mod 2 ** 8;
>  for unsigned_8'size use 8;
>
>When I try to compile (gnat 2.03 for OS/2), I get:
>  f:\EMX\GNATLIB\a-sequio.adb:33:59: actual for "Element_Type"
>    must be a definite subtype

- Bob



^ permalink raw reply	[relevance 7%]

* ada.sequential_io problem
@ 1995-03-14  6:44 13% Tore Joergensen
  1995-03-14 14:01  7% ` Robert A Duff
  1995-03-15 11:00  6% ` Pascal OBRY
  0 siblings, 2 replies; 130+ results
From: Tore Joergensen @ 1995-03-14  6:44 UTC (permalink / raw)


What is wrong???

I tried to define:
  package bio is new ada.sequential_io(unsigned_8);

Unsigned_8 is defined in the package interfaces as:
  type unsigned_8 is mod 2 ** 8;
  for unsigned_8'size use 8;

When I try to compile (gnat 2.03 for OS/2), I get:
  f:\EMX\GNATLIB\a-sequio.adb:33:59: actual for "Element_Type"
    must be a definite subtype

LRM 3.5.4 (10):
"... A modular_type_definition also defines a constrained first subtype
of the type with a range that is the same as the base range of the type."

LRM 3.3 (23):
"... A subtype is an indefinite subtype if it is an unconstrained array
subtype, or if it has unknown discriminants or unconstrained discriminants
without defaults (see 3.7); otherwise the subtype is a definite subtype
(all elementary subtypes are definite subtypes). ..."

I can't figure out what is wrong with my package-definition. I even tried
to make it with integer (the rationale (part2.II.11) says that integer is
a definite type)
   package bio is new ada.sequential_io(integer);
but I got the same error. Can the problem be that the sequential_io package
uses storage_io where the Element_type is defined as private, while the
sequential_io defines Element_type(<>) as private? If this is the problem,
doesn't that mean that sequential_io will never work?

Any help will be appreciated!

--
______________________________________________________________________
Tore B. Joergensen,    |    e-mail:     tore@lis.pitt.edu
a norwegian student    |    snail-mail: 2201 Pittockstr.
a long way from home.  |                Pittsburgh, 15217 PA
                       |    web:        http://www.pitt.edu/~tojst1



^ permalink raw reply	[relevance 13%]

* Re:  VAX Ada sequential IO and Direct IO
@ 1987-04-14  1:17  0% gary
  0 siblings, 0 replies; 130+ results
From: gary @ 1987-04-14  1:17 UTC (permalink / raw)


> Has anyone had problems with VAX Ada sequential_io and direct_IO when
> instantiated with a discriminated record type which has an unconstrained
> component.  I keep getting use_error raised when doing a create or open.
> 
> example
> 
> 
> type foo(a : integer) is
> 	record
> 	   f1 : string(1..a);
> 	end record;
> 
> even if I restrict the range of 'a' by using a subtype of integer, or
> create an integer type with a restricted range I still get a use_error.
> In addition to the use error, an RMS error is listed as max record size 
> exceeded.
> 
> 	... Tony Alden
> 	(TRW)
> 
> 
We've been able to use sequential and direct io with discrimant
records successfully by specifying a default discriminant value,
i.e. the records have to be "constrained" at time of
instantiation of io package.

	You might try something like the following:

  type foo(a : integer := MAXLENGTH) is
  	record
  	   f1 : string(1..a);
  	end record;
  
  package rec_io is new sequential_io(foo);


	Good Luck,

				Gary Gafke
				gary@aplpy.arpa
			or	seismo!mimsy!aplcen!gary
			or	(301) 953-6999

^ permalink raw reply	[relevance 0%]

* VAX Ada sequential IO and Direct IO
@ 1987-04-09  3:32  5% alden
  0 siblings, 0 replies; 130+ results
From: alden @ 1987-04-09  3:32 UTC (permalink / raw)


Has anyone had problems with VAX Ada sequential_io and direct_IO when
instantiated with a discriminated record type which has an unconstrained
component.  I keep getting use_error raised when doing a create or open.

example


type foo(a : integer) is
	record
	   f1 : string(1..a);
	end record;

even if I restrict the range of 'a' by using a subtype of integer, or
create an integer type with a restricted range I still get a use_error.
In addition to the use error, an RMS error is listed as max record size 
exceeded.

	... Tony Alden
	(TRW)

^ permalink raw reply	[relevance 5%]

Results 1-130 of 130 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
1987-04-09  3:32  5% VAX Ada sequential IO and Direct IO alden
1987-04-14  1:17  0% gary
1995-03-14  6:44 13% ada.sequential_io problem Tore Joergensen
1995-03-14 14:01  7% ` Robert A Duff
1995-03-15 11:00  6% ` Pascal OBRY
     [not found]     <00001a73+00002504@msn.com>
     [not found]     ` <4etcmm$lpd@nova.dimensional.com>
     [not found]       ` <3114d8fb.5a455349@zesi.ruhr.de>
     [not found]         ` <4f5h5t$f13@vixen.cso.uiuc.edu>
     [not found]           ` <4g1bgf$l5@mailhub.scitec.com.au>
     [not found]             ` <312515DF.7D3B@cmlj.demon.co.uk>
1996-02-18  0:00               ` C/C++ knocks the crap out of Ada ++           robin
1996-02-19  0:00                 ` Richard A. O'Keefe
1996-02-20  0:00                   ` Robert Dewar
1996-02-22  0:00                     ` Richard A. O'Keefe
1996-02-22  0:00                       ` C/C++ ... " Norman H. Cohen
1996-02-23  0:00  6%                     ` Richard A. O'Keefe
1996-07-09  0:00  6% Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
1996-07-09  0:00  0% ` Michael Paus
1996-07-09  0:00  6% ` Robert Dewar
1997-03-02  0:00     CRC in Ada? Dr. John B. Matthews
1997-03-04  0:00     ` Stephen Garriga
1997-03-04  0:00       ` Robert Dewar
1997-03-15  0:00         ` Michael & Amy Hartsough
1997-03-16  0:00           ` Robert Dewar
1997-03-16  0:00             ` Michael & Amy Hartsough
1997-03-16  0:00               ` Robert Dewar
1997-03-18  0:00                 ` Michael & Amy Hartsough
1997-03-19  0:00  6%               ` Robert Dewar
1997-03-05  0:00     ` Larry Kilgallen
1997-03-05  0:00       ` Robert A Duff
1997-03-05  0:00         ` Larry Kilgallen
1997-03-06  0:00           ` Robert A Duff
1997-03-06  0:00             ` Robert Dewar
1997-03-09  0:00  6%           ` Dr. John B. Matthews
1997-03-05  0:00  4% ` David C. Hoos, Sr.
1997-03-28  0:00     file locking in Ada Neil Goodgame
1997-03-30  0:00  5% ` Nick Roberts
     [not found]     <335358C5.43F8@reading.ac.uk>
1997-04-16  0:00  4% ` Segmentation Fault William Paul Berriss
1997-06-18  0:00     GNAT: Handling of textfile end-of-page Jakob Heinemann
1997-06-19  0:00  6% ` Anonymous
1997-06-20  0:00  7%   ` Robert Dewar
1997-10-11  0:00     File handling Hannu �rn
1997-10-15  0:00  5% ` Matthew Heaney
     [not found]     <348345B4.6E26@eng.clemson.edu>
1997-12-03  0:00  6% ` File IO Jerry van Dijk
1998-07-07  0:00     [Q]Gnat on Linux grave
1998-07-07  0:00     ` Markus Kuhn
1998-07-08  0:00  6%   ` grave
1998-09-10  0:00  1% Learn Ada 95! - Free Ada-Belgium course starts 98/09/23 Dirk Craeynest
1998-11-10  0:00     Binary Files in Text Editor robinsoj
1998-11-11  0:00     ` robinsoj
1998-11-12  0:00       ` John McCabe
1998-11-12  0:00         ` robinsoj
1998-11-14  0:00  7%       ` Jerry van Dijk
1999-06-19  0:00     Dynamic Array Sizing Nick Wilson
1999-06-19  0:00  5% ` jerry
1999-07-21  0:00     Binary File Manip. - Possibly a stupid question Matthew
1999-07-20  0:00  4% ` Ted Dennison
1999-11-28  0:00  4% Decoding an octet stream Florian Weimer
1999-11-29  0:00  0% ` David C. Hoos, Sr.
2000-01-11  0:00     Ada Communications TAMS Team
2000-01-11  0:00  4% ` Ted Dennison
2000-08-20  0:00     Reading/writing LPT1 David Boman
2000-08-21  0:42     ` tmoran
2000-08-21  0:00       ` David Boman
2000-08-21  0:00  4%     ` Ted Dennison
2000-09-28  0:00     File I/O stiletto
2000-09-29  3:15  5% ` tmoran
2001-01-21 21:30  1% Learn Ada! - Free Ada-Belgium course starts Jan 24 Dirk Craeynest
2001-01-22  0:05  5% Optimization Question dvdeug
2001-03-13  0:35     text_io is not a predefined library Andrew Busolin
2001-03-13  4:54     ` DuckE
2001-03-13 10:47  7%   ` David C. Hoos, Sr.
     [not found]     <n5su6.24687$CL6.767652@telenews.teleline.es>
2001-03-26 14:08     ` Binary Data File - PLEASE HELP Sergio
2001-03-26 14:56  5%   ` Ted Dennison
2001-03-26 15:21  6%   ` Martin Dowie
2001-11-25 22:42  5% Text_IO.End_Of_File Problem Hambut
2001-11-26  1:53  0% ` Jeffrey Carter
2001-11-26  2:35  7% ` Nick Roberts
2001-11-26 12:13  0%   ` Hambut
2001-12-13  3:23     List Container Strawman 1.4 Ted Dennison
2001-12-13 23:02     ` Nick Roberts
2001-12-14 15:19       ` Ted Dennison
2001-12-15  1:20  1%     ` Nick Roberts
2001-12-15 20:29  0%       ` Ted Dennison
2001-12-16 18:45  0%         ` Nick Roberts
2002-02-21 20:25     How to speed up stream & record handling? Florian Weimer
2002-02-21 23:59  5% ` tmoran
2002-02-25 17:08     reading from a file Deepie
2002-02-25 17:23     ` John McCabe
2002-02-25 20:30       ` Deepie
2002-02-25 20:46         ` sk
2002-02-26  9:20  7%       ` John McCabe
     [not found]     <mailman.1031406782.31963.comp.lang.ada@ada.eu.org>
2002-09-07 15:32  5% ` Diffrence between a sequential binairies file and direct binairies file Nick Roberts
2003-10-14 14:42  5% [Fwd: Re: SEQUENTIA_IO and stdin/stdout] Marius Amado Alves
2003-11-03 15:56     Read Binary File Frank Mattison
2003-11-03 22:34  5% ` Gautier Write-only
2003-11-05 10:11  6% ` Thierry Lelegard
2004-03-06 19:09     abstract sub programs overriding Marius Amado Alves
2004-03-07 12:35     ` Simon Wright
2004-03-08 19:08       ` Adam Beneschan
2004-03-08 20:03         ` Hyman Rosen
2004-03-09  8:51           ` Dmitry A. Kazakov
2004-03-09 13:34             ` Hyman Rosen
2004-03-09 14:49               ` Dmitry A. Kazakov
2004-03-09 15:14                 ` Hyman Rosen
2004-03-09 15:56                   ` Dmitry A. Kazakov
2004-03-09 16:32                     ` Hyman Rosen
2004-03-10  9:32                       ` Dmitry A. Kazakov
2004-03-10 13:08                         ` Hyman Rosen
2004-03-10 14:58  4%                       ` Robert I. Eachus
2004-07-20 21:25     Stack overflow using Xml/Ada Jano
2004-07-21  7:37  5% ` Emmanuel Briot
2004-07-21  8:02  0%   ` Jano
2004-10-04 19:16     excel files Alexandre Devaure
2004-10-04 19:42     ` stephane richard
2004-10-05  0:29  5%   ` Jeffrey Carter
2005-03-01  9:30  5% Advanced file manipulation (multiple question) Steph-ADA
2005-03-01  9:59  0% ` Peter Hermann
2005-03-01 12:18  0% ` Larry Kilgallen
2005-03-01 17:49  0% ` Jeffrey Carter
2005-03-02  2:42  0% ` Steve
2005-06-15  9:57     Data table text I/O package? Jacob Sparre Andersen
2005-06-15 11:43     ` Preben Randhol
2005-06-15 13:35       ` Jacob Sparre Andersen
2005-06-15 14:12         ` Preben Randhol
2005-06-15 15:02           ` Jacob Sparre Andersen
2005-06-15 18:58             ` Randy Brukardt
2005-06-16  9:55               ` Jacob Sparre Andersen
2005-06-30  3:02                 ` Randy Brukardt
2005-06-30 18:43  3%               ` Jacob Sparre Andersen
2005-09-01 20:28     File TC
2005-09-01 21:43  5% ` File Martin Dowie
2005-09-02 15:39  0%   ` File Martin Krischik
2006-04-02  2:47  4% Advice on low level file handling Peter C. Chapin
2006-04-04  1:31  0% ` Randy Brukardt
2007-01-30 15:51     Reading Float Data from a binary file into ada frikk
2007-01-30 19:31  6% ` Niklas Holsti
2007-02-21 20:43     Ada.Command_Line and wildcards Gautier
2007-02-21 20:59     ` (see below)
2007-02-22  8:16       ` gautier_niouzes
2007-02-22 11:19         ` Jean-Pierre Rosen
2007-02-23  1:15           ` Robert A Duff
2007-02-23  9:25             ` Jacob Sparre Andersen
2007-02-24  1:18               ` typed pipes (was: Ada.Command_Line and wildcards) Björn Persson
2007-02-24 13:37                 ` typed pipes Jacob Sparre Andersen
2007-02-24 16:33                   ` Björn Persson
2007-02-24 20:17  5%                 ` Jacob Sparre Andersen
2007-02-25  1:11  0%                   ` Björn Persson
2007-03-09 22:43     Design help Carroll, Andrew
2007-03-10 13:38  6% ` Ludovic Brenta
2007-03-13  0:50  7% Carroll, Andrew
2008-03-08 21:22     Files and controlled types Maciej Sobczak
2008-03-09  3:12  5% ` Jeffrey R. Carter
2008-03-09 13:27  0%   ` Maciej Sobczak
2008-03-10 15:37  0%     ` Adam Beneschan
2008-03-09 16:39  0%   ` gpriv
2008-08-18 13:40  5% File "form" and mainstream systems Maciej Sobczak
2008-08-22  4:00  0% ` Randy Brukardt
2009-01-01 11:16     Ada.Directories problems, a summary Dmitry A. Kazakov
2009-01-01 20:41  3% ` anon
2009-02-16 20:36     C getchar() functionality in Ada Thomas Locke
2009-02-16 21:43     ` Jeffrey R. Carter
2009-02-17  7:23       ` Thomas Locke
2009-02-17  8:16  6%     ` Niklas Holsti
2009-02-17 13:01  0%       ` Georg Bauhaus
2009-04-03 12:01     Load an object from a file Olivier Scalbert
2009-04-03 13:37     ` Ludovic Brenta
2009-04-09 20:32  4%   ` Olivier Scalbert
2009-05-04  9:08     How to exit an Ada program with (unix shell) error code? reinkor
2009-05-06 15:28     ` Adam Beneschan
2009-05-07  9:08  4%   ` anon
2009-05-13 14:16     newbie problem Olivier Scalbert
2009-05-13 14:54  5% ` Martin
2009-05-13 15:20  6%   ` Olivier Scalbert
2009-05-13 15:44  7% ` Ludovic Brenta
2009-05-13 18:00  6% ` Olivier Scalbert
2009-05-13 18:51  0%   ` Martin
2009-05-13 19:48         ` Olivier Scalbert
2009-05-14 19:41           ` sjw
2009-05-18 10:23  7%         ` Olivier Scalbert
2009-05-18 10:48  0%           ` Martin
2009-05-18 10:52  7%           ` Ludovic Brenta
2009-05-18 11:09  0%             ` Olivier Scalbert
2009-05-14  2:59  5% ` anon
2009-05-28 18:26     Ada extension information info
2009-05-30  7:13  3% ` anon
2009-05-30 10:13  0%   ` info
2009-08-26 10:22     Generalized serialization for enumeration types xorque
2009-08-26 11:17  6% ` Georg Bauhaus
2009-10-24 22:07     Preferred way to do binray I/O on standard input/output stream Hibou57 (Yannick Duchêne)
2009-10-24 22:57  5% ` Jeffrey R. Carter
2010-08-20 23:23     Binary opperations under Ada? Trogdor
2010-08-21  0:17  5% ` Jeffrey Carter
2010-11-17  4:44     Encapsulating Ada.Direct_IO Bryan
2010-11-17 12:25     ` Peter C. Chapin
2010-11-18  1:16       ` Randy Brukardt
2010-11-18  2:21  5%     ` Peter C. Chapin
2010-11-18 16:36  0%       ` Adam Beneschan
2012-03-25 14:28     xor Michael Moeller
2012-03-25 14:01     ` xor Niklas Holsti
2012-03-25 15:16       ` xor Michael Moeller
2012-03-25 19:26  4%     ` xor Niklas Holsti
2012-03-27 20:09  0%       ` xor Michael Moeller
2016-08-12  4:05     How to write "Hello" to a text file without a line terminator Jerry
2016-08-12  7:23     ` Dmitry A. Kazakov
2016-08-12  7:44       ` Jerry
2016-08-12 17:34  4%     ` Jeffrey R. Carter
2016-08-13  3:21  7%       ` Jerry
2016-08-13  4:23  0%         ` Jeffrey R. Carter
2016-08-13  9:12  0%           ` AdaMagica
2016-08-13 18:03  6%             ` Jeffrey R. Carter
2016-08-14  7:58                   ` AdaMagica
2016-08-14  8:30  7%                 ` Simon Wright
2016-08-14 13:28  5%                   ` AdaMagica
2017-09-03 11:01  6% quiz for Sequential_IO Read Frank Buss
2017-09-03 12:26  0% ` Dmitry A. Kazakov
2017-09-03 12:43  0%   ` Frank Buss
2017-09-03 13:11  0%     ` Dmitry A. Kazakov
2017-12-08 16:04     How To Write A Record To File ? patrick
2017-12-08 16:25     ` AdaMagica
2017-12-08 16:41       ` patrick
2017-12-08 16:57  5%     ` Anh Vo
2017-12-08 17:11  0%       ` Anh Vo
2018-10-04 21:38     A little trouble with very large arrays Shark8
2018-10-05  6:17  5% ` Jacob Sparre Andersen
2020-12-21  4:59  4% Read/write access to Unix character devices philip...@gmail.com
2020-12-22  1:23  5% ` Randy Brukardt
2020-12-28 13:26  0% ` Björn Lundin
2021-03-22 17:13  5% surprise data from Ada.Sequential_IO John Perry
2021-03-22 17:40  6% ` Jeffrey R. Carter
2021-03-22 18:14  6%   ` John Perry
2021-03-22 19:41  6%     ` Jeffrey R. Carter
2021-03-22 20:54 14%       ` Niklas Holsti
2021-03-23  9:18  7%         ` Jeffrey R. Carter
2021-03-22 21:25  6%       ` Shark8
2021-03-22 17:48  6% ` Dmitry A. Kazakov
2022-11-21  8:30     String view of file Jesper Quorning
2022-11-21 13:48  6% ` Jeffrey R.Carter
2022-11-21 15:52  0%   ` Niklas Holsti
2022-11-21 16:11  5% ` Marius Amado-Alves
2023-06-25  4:37     I have gnat 13.1.0 on my M1 Mac; I'd like to have my own Ada+GNAT *.ad[sb] library files, where are they? Kenneth Wolcott
2023-06-25 10:15  4% ` Simon Wright
2023-06-25 15:28  0%   ` Simon Wright
2023-06-25 17:00  0%   ` Kenneth Wolcott
2023-06-25 21:49  0%   ` Keith Thompson
2023-06-26 18:56  0%     ` Jere
2023-06-26 19:35  0%       ` Kenneth Wolcott
2023-06-26 19:48  0%       ` Simon Wright

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