comp.lang.ada
 help / color / mirror / Atom feed
* Learning Ada
@ 1985-09-03  2:46 Marty Sasaki
  0 siblings, 0 replies; 152+ messages in thread
From: Marty Sasaki @ 1985-09-03  2:46 UTC (permalink / raw)


I've decided that is time to learn Ada.  What's the best way to do
this?  Which books are interesting and useful?

I don't need to learn to program (I'm semi-fluent in C, Pascal,
FORTRAN, and have dabbled with Modula-2, CLU, and many more that I
can't remember).  I need to get an overview of the language, and a
glimpse of some of the paradigms.
-- 
----------------
  Marty Sasaki				net:   sasaki@harvard.{arpa,uucp}
  Havard University Science Center	phone: 617-495-1270
  One Oxford Street
  Cambridge, MA 02138

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

* Re: Learning Ada
       [not found] <332@harvard.UUCP>
@ 1985-09-04 16:07 ` richw
  0 siblings, 0 replies; 152+ messages in thread
From: richw @ 1985-09-04 16:07 UTC (permalink / raw)



A popular book here at Intermetrics (i.e. Ada compiler-writers)
is ``Software Engineering with Ada'', by Grady Booch
(The Benjamin/Cummings Publishing Co., Inc., 1983).

Other than its popularity, though, I can't say whether anything
else exists which is measurably better (having just started
learning myself).

Have fun...

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

* Learning Ada
@ 1985-09-06 15:10 Marty Sasaki
  0 siblings, 0 replies; 152+ messages in thread
From: Marty Sasaki @ 1985-09-06 15:10 UTC (permalink / raw)


I tried to reply to every message that I received, but the mailer
returned many as undeliverable. Sorry to post this.

Anyway, thanks to everyone for their recommendations and general
advice. I'll wander down to the Coop and look at the recommendations
in the next few days.

		Marty Sasaki

-- 
----------------
  Marty Sasaki				net:   sasaki@harvard.{arpa,uucp}
  Havard University Science Center	phone: 617-495-1270
  One Oxford Street
  Cambridge, MA 02138

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

* Learning ADA
@ 1989-06-15  1:48 Krishan M Nainani
  1989-06-15 14:19 ` Rosa Weber
  0 siblings, 1 reply; 152+ messages in thread
From: Krishan M Nainani @ 1989-06-15  1:48 UTC (permalink / raw)



I am interested in learning Ada. Can anyone recommend a good book
which is not VERY basic since I do know C and Pascal and have a
good knowledge of multi-processing.

Please reply to: tfrancis@wpi.wpi.edu

Krishan Nainani

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

* Re: Learning ADA
  1989-06-15  1:48 Learning ADA Krishan M Nainani
@ 1989-06-15 14:19 ` Rosa Weber
  0 siblings, 0 replies; 152+ messages in thread
From: Rosa Weber @ 1989-06-15 14:19 UTC (permalink / raw)



Try "Software Engineering with ADA" (second edition), by Grady Booch,
The Benjamin/Cummings Publishing Company, Inc., 1986.

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

* Re: learning ada
       [not found] <36841f24.293012@news.ptd.net>
@ 1998-12-25  0:00 ` LeakyStain
  1998-12-26  0:00   ` David Botton
  0 siblings, 1 reply; 152+ messages in thread
From: LeakyStain @ 1998-12-25  0:00 UTC (permalink / raw)


bob wrote:
> 
>         hey everyone, i am a student learning ADA at college right
> now. i am considering going for a master's degree in software
> engineering to go along with a BA in comp. engineering.  i have
> completed a course in ada, and will have one more course this next
> semester.  i really want to get a good knowledge of this language, but
> we never do anything like what everyone talks about in here because it
> is more advanced.  i was wondering what the best way to go about
> learning more in depth of the language, what is the best way?  thanks
> in advance

First, go to www.adahome.com, and browse around a bit, so you know what
sort of resources are available. Work thru the Lovelace tutorial, if you
haven't done that already. Buy one of the recommended books (my favorite
is Cohen's 'Ada as a Second Language'). 

Then pick a program you'd like to write; a card game, a spreadsheet,
whatever turns you on. Start writing it. You'll do it badly, but you
don't need to show it to anyone. Look up anything you don't know how to
do. When you're done, go back and fix it up, so it's more elegant, or
uses some feature of Ada you didn't use the first time (tagged types or
generics or Finalization). Most of all, keep it fun!

> 
> jarrod ross

-- Stephe




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

* Re: learning ada
  1998-12-25  0:00 ` learning ada LeakyStain
@ 1998-12-26  0:00   ` David Botton
  0 siblings, 0 replies; 152+ messages in thread
From: David Botton @ 1998-12-26  0:00 UTC (permalink / raw)


Also check out www.botton.com/ada TheAda Source Code Treasury for examples
of code and join the mail list tehre so you get updates when new code is
added.

David Botton

LeakyStain wrote in message <36845EC8.6795772B@erols.com>...
>bob wrote:
>>
>>         hey everyone, i am a student learning ADA at college right
>> now. i am considering going for a master's degree in software
>> engineering to go along with a BA in comp. engineering.  i have
>> completed a course in ada, and will have one more course this next
>> semester.  i really want to get a good knowledge of this language, but
>> we never do anything like what everyone talks about in here because it
>> is more advanced.  i was wondering what the best way to go about
>> learning more in depth of the language, what is the best way?  thanks
>> in advance
>
>First, go to www.adahome.com, and browse around a bit, so you know what
>sort of resources are available. Work thru the Lovelace tutorial, if you
>haven't done that already. Buy one of the recommended books (my favorite
>is Cohen's 'Ada as a Second Language').
>
>Then pick a program you'd like to write; a card game, a spreadsheet,
>whatever turns you on. Start writing it. You'll do it badly, but you
>don't need to show it to anyone. Look up anything you don't know how to
>do. When you're done, go back and fix it up, so it's more elegant, or
>uses some feature of Ada you didn't use the first time (tagged types or
>generics or Finalization). Most of all, keep it fun!
>
>>
>> jarrod ross
>
>-- Stephe






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

* unsigned type
@ 2009-06-28 15:36 Rob Solomon
  2009-06-28 15:45 ` Florian Weimer
                   ` (3 more replies)
  0 siblings, 4 replies; 152+ messages in thread
From: Rob Solomon @ 2009-06-28 15:36 UTC (permalink / raw)


I am trying to learn Ada.  I am very familiar w/ Modula-2.

I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
compiler.  I know Ada does not have a type CARDINAL, but I thought it
had a type Unsigned.

How do I declare such a variable?

Thanks



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

* Re: unsigned type
  2009-06-28 15:36 unsigned type Rob Solomon
@ 2009-06-28 15:45 ` Florian Weimer
  2009-06-28 15:48 ` Albrecht Käfer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 152+ messages in thread
From: Florian Weimer @ 2009-06-28 15:45 UTC (permalink / raw)


* Rob Solomon:

> I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
> compiler.  I know Ada does not have a type CARDINAL, but I thought it
> had a type Unsigned.

The usual integer type whose values do not include negative numbers is
called Natural.



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

* Re: unsigned type
  2009-06-28 15:36 unsigned type Rob Solomon
  2009-06-28 15:45 ` Florian Weimer
@ 2009-06-28 15:48 ` Albrecht Käfer
  2009-06-28 17:56 ` anon
  2009-06-29 16:51 ` Martin Krischik
  3 siblings, 0 replies; 152+ messages in thread
From: Albrecht Käfer @ 2009-06-28 15:48 UTC (permalink / raw)


Rob Solomon schrieb:
> I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
> compiler.  I know Ada does not have a type CARDINAL, but I thought it
> had a type Unsigned.
>
> How do I declare such a variable?

Ada has types Positive (1..maxint) and Natural (0..maxint). However, you
might mean a modular type, i. e. one where maxint+1=0 instead of raising
an exception. See http://en.wikibooks.org/wiki/Ada_Programming/Types/mod


Albrecht



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

* Re: unsigned type
  2009-06-28 15:36 unsigned type Rob Solomon
  2009-06-28 15:45 ` Florian Weimer
  2009-06-28 15:48 ` Albrecht Käfer
@ 2009-06-28 17:56 ` anon
  2009-06-28 19:17   ` Ludovic Brenta
  2009-06-28 19:54   ` tmoran
  2009-06-29 16:51 ` Martin Krischik
  3 siblings, 2 replies; 152+ messages in thread
From: anon @ 2009-06-28 17:56 UTC (permalink / raw)


with Interfaces ;  --  
use  Interfaces ;  -- 

Unless you need a special type just uses the predefined types in this package.  
Such as:
   Unsigned_8  ; --  8 bit
   Unsigned_16 ; -- 16 bit
   Unsigned_32 ; -- 32 bit
   Unsigned_64 ; -- 64 bit


In <eb3f45l5378gipiqeomr67uvtsdan84ihk@4ax.com>, Rob Solomon <usenet@drrob1-noreply.com> writes:
>I am trying to learn Ada.  I am very familiar w/ Modula-2.
>
>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
>compiler.  I know Ada does not have a type CARDINAL, but I thought it
>had a type Unsigned.
>
>How do I declare such a variable?
>
>Thanks




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

* Re: unsigned type
  2009-06-28 17:56 ` anon
@ 2009-06-28 19:17   ` Ludovic Brenta
  2009-06-28 23:08     ` anon
  2009-06-28 19:54   ` tmoran
  1 sibling, 1 reply; 152+ messages in thread
From: Ludovic Brenta @ 2009-06-28 19:17 UTC (permalink / raw)


anon wrote on comp.lang.ada
> with Interfaces ;  --  
> use  Interfaces ;  --
>
> Unless you need a special type just uses the predefined types in this package.  

Note that you will need a special type most of the time; you'd use
Interfaces.Unsigned_* only when interfacing with hardware or other
compilers.  Similarly, you should not use the predefined types
Integer, Natural or Positive to represent your problem domain's
entities; use them only when interfacing with the predefined library
(Ada.*).

--
Ludovic Brenta.



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

* Re: unsigned type
  2009-06-28 17:56 ` anon
  2009-06-28 19:17   ` Ludovic Brenta
@ 2009-06-28 19:54   ` tmoran
  2009-06-28 22:34     ` Gary Scott
  2009-06-29 13:36     ` Rob Solomon
  1 sibling, 2 replies; 152+ messages in thread
From: tmoran @ 2009-06-28 19:54 UTC (permalink / raw)


>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
>compiler.  I know Ada does not have a type CARDINAL, but I thought it
>had a type Unsigned.

Ada's equivalent is Natural.  If
  Lowest : Natural := 0;
  Highest : Natural := Natural'last;
then
  Lowest  := Lowest-1;  -- will raise an exception
  Highest := Highest+1; -- ditto

(Note that Gnat by default is not a legal Ada compiler because it doesn't
check for and raise the exception.  You need a command line parameter
-gnato to make it act like Ada.)

The standard Ada package Interfaces has hardware-oriented types
Unsigned_8, Unsigned_16, etc but those are modular types so if
  Empty_Word : Interfaces.Unsigned_16 := 0;
  Full_Byte  : Interfaces.Unsigned_8 := 255;
then
  Empty_Word-1 will be 65535.
  Full_Byte+1 will be 0.
with no exceptions raised.

You can also declare your own application oriented non-negative types
  type Ratings is range 1 .. 10;
or modular types
  type Degrees is mod 360;  -- 0 .. 359 wrapping around



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

* Re: unsigned type
  2009-06-28 19:54   ` tmoran
@ 2009-06-28 22:34     ` Gary Scott
  2009-06-28 23:15       ` John B. Matthews
                         ` (2 more replies)
  2009-06-29 13:36     ` Rob Solomon
  1 sibling, 3 replies; 152+ messages in thread
From: Gary Scott @ 2009-06-28 22:34 UTC (permalink / raw)


tmoran@acm.org wrote:

>>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
>>compiler.  I know Ada does not have a type CARDINAL, but I thought it
>>had a type Unsigned.
> 
> 
> Ada's equivalent is Natural.  If

Sorry for the naive question.  I'm curious as to the reason for the term 
"natural".  "Unnatural" would seem more descriptive :)


>   Lowest : Natural := 0;
>   Highest : Natural := Natural'last;
> then
>   Lowest  := Lowest-1;  -- will raise an exception
>   Highest := Highest+1; -- ditto
> 
> (Note that Gnat by default is not a legal Ada compiler because it doesn't
> check for and raise the exception.  You need a command line parameter
> -gnato to make it act like Ada.)
> 
> The standard Ada package Interfaces has hardware-oriented types
> Unsigned_8, Unsigned_16, etc but those are modular types so if
>   Empty_Word : Interfaces.Unsigned_16 := 0;
>   Full_Byte  : Interfaces.Unsigned_8 := 255;
> then
>   Empty_Word-1 will be 65535.
>   Full_Byte+1 will be 0.
> with no exceptions raised.
> 
> You can also declare your own application oriented non-negative types
>   type Ratings is range 1 .. 10;
> or modular types
>   type Degrees is mod 360;  -- 0 .. 359 wrapping around


-- 

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library:  http://www.fortranlib.com

Support the Original G95 Project:  http://www.g95.org
-OR-
Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows 
it can't be done.

-- Henry Ford



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

* Re: unsigned type
  2009-06-28 19:17   ` Ludovic Brenta
@ 2009-06-28 23:08     ` anon
  2009-06-29  0:19       ` tmoran
  2009-06-29  8:42       ` Martin
  0 siblings, 2 replies; 152+ messages in thread
From: anon @ 2009-06-28 23:08 UTC (permalink / raw)


Yea, Right! Like, how many people need a trinary system. There are a few, a 
very few! 

And as for Natural, well, that is the definition of a String's index and in most 
cases you use Naturals in "for loop' statements.

And if you use the standard types instead of creating your own you 
would save problem when another modifies the program! Alway use standard 
if possible, That way every program rather Ada or C or etc known the type 
and the range. 

Never create your own types unless lives are an issue. And most who use 
GPL GNAT are not writting program where lives matter.


In <36286c5a-99f0-4ed9-8ef0-11d7af230216@e21g2000yqb.googlegroups.com>, Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>anon wrote on comp.lang.ada
>> with Interfaces ; =A0-- =A0
>> use =A0Interfaces ; =A0--
>>
>> Unless you need a special type just uses the predefined types in this pac=
>kage. =A0
>
>Note that you will need a special type most of the time; you'd use
>Interfaces.Unsigned_* only when interfacing with hardware or other
>compilers.  Similarly, you should not use the predefined types
>Integer, Natural or Positive to represent your problem domain's
>entities; use them only when interfacing with the predefined library
>(Ada.*).
>
>--
>Ludovic Brenta.




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

* Re: unsigned type
  2009-06-28 22:34     ` Gary Scott
@ 2009-06-28 23:15       ` John B. Matthews
  2009-06-28 23:21       ` anon
  2009-06-29  7:18       ` Dmitry A. Kazakov
  2 siblings, 0 replies; 152+ messages in thread
From: John B. Matthews @ 2009-06-28 23:15 UTC (permalink / raw)


In article <1eS1m.2153$j84.1865@nlpi061.nbdc.sbc.com>,
 Gary Scott <garylscott@sbcglobal.net> wrote:

> tmoran@acm.org wrote:
[...]
> > Ada's equivalent is Natural.
> 
> Sorry for the naive question.  I'm curious as to the reason for the 
> term "natural".  "Unnatural" would seem more descriptive :)

Well, there's this:

<http://en.wikipedia.org/wiki/Natural_number>

The package Standard says, in part:

   type Integer is range implementation-defined;

      subtype Natural  is Integer range 0 .. Integer'Last;
      subtype Positive is Integer range 1 .. Integer'Last;

<http://www.adaic.com/standards/05rm/html/RM-A-1.html>

Sadly, I've had to look it up more than once. :-)

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



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

* Re: unsigned type
  2009-06-28 22:34     ` Gary Scott
  2009-06-28 23:15       ` John B. Matthews
@ 2009-06-28 23:21       ` anon
  2009-06-29  7:18       ` Dmitry A. Kazakov
  2 siblings, 0 replies; 152+ messages in thread
From: anon @ 2009-06-28 23:21 UTC (permalink / raw)


"Natural" "Positive" definition: come from Mathematics and for Ada the Ada 
Language reference Manual ( Ada RM ) define in the Standard package.
 
And all packages are defines as a child of the Standard package. Now for the 
Integer, Natural and Positive data types the value for a 32-bit system follows
And in a 64 bit system the types would be based on "2 ** 64" instead of
"2 ** 32". 

package Standard is

   type Integer is range -(2 ** 31) .. +(2 ** 31 - 1);

   subtype Natural  is Integer range 0 .. +(2 ** 31 - 1);
   subtype Positive is Integer range 1 .. +(2 ** 31 - 1);
 ...
end Standard ;


In <1eS1m.2153$j84.1865@nlpi061.nbdc.sbc.com>, Gary Scott <garylscott@sbcglobal.net> writes:
>tmoran@acm.org wrote:
>
>>>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
>>>compiler.  I know Ada does not have a type CARDINAL, but I thought it
>>>had a type Unsigned.
>> 
>> 
>> Ada's equivalent is Natural.  If
>
>Sorry for the naive question.  I'm curious as to the reason for the term 
>"natural".  "Unnatural" would seem more descriptive :)
>
>
>>   Lowest : Natural := 0;
>>   Highest : Natural := Natural'last;
>> then
>>   Lowest  := Lowest-1;  -- will raise an exception
>>   Highest := Highest+1; -- ditto
>> 
>> (Note that Gnat by default is not a legal Ada compiler because it doesn't
>> check for and raise the exception.  You need a command line parameter
>> -gnato to make it act like Ada.)
>> 
>> The standard Ada package Interfaces has hardware-oriented types
>> Unsigned_8, Unsigned_16, etc but those are modular types so if
>>   Empty_Word : Interfaces.Unsigned_16 := 0;
>>   Full_Byte  : Interfaces.Unsigned_8 := 255;
>> then
>>   Empty_Word-1 will be 65535.
>>   Full_Byte+1 will be 0.
>> with no exceptions raised.
>> 
>> You can also declare your own application oriented non-negative types
>>   type Ratings is range 1 .. 10;
>> or modular types
>>   type Degrees is mod 360;  -- 0 .. 359 wrapping around
>
>
>-- 
>
>Gary Scott
>mailto:garylscott@sbcglobal dot net
>
>Fortran Library:  http://www.fortranlib.com
>
>Support the Original G95 Project:  http://www.g95.org
>-OR-
>Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html
>
>If you want to do the impossible, don't hire an expert because he knows 
>it can't be done.
>
>-- Henry Ford




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

* Re: unsigned type
  2009-06-28 23:08     ` anon
@ 2009-06-29  0:19       ` tmoran
  2009-06-29  8:00         ` anon
  2009-06-29  8:42       ` Martin
  1 sibling, 1 reply; 152+ messages in thread
From: tmoran @ 2009-06-29  0:19 UTC (permalink / raw)


> And as for Natural, well, that is the definition of a String's index
  false.
> and in most cases you use Naturals in "for loop' statements.
  false.

> And if you use the standard types instead of creating your own you
> would save problem when another modifies the program!
  unlikely.

> Alway use standard if possible,
  Most experienced Ada programmers would say the opposite.

> That way every program rather Ada or C or etc known the type
> and the range.
  false.  I can't count the number of times I had to change a
program that assumed that, say, the standard type Integer was 32 bits.
(And almost never was it reasonable for a variable of the type in
question to have a value of plus or minus a couple of billion.)

> Never create your own types unless lives are an issue.
  Most Ada programmers would say your programs are more likely to be
correct if you welcome, rather than refuse, assistance from the compiler.
If you define your own types, the compiler can check that you aren't
erroneously adding Number_Of_Apples to Miles_Travelled, and that
Miles_Travelled is within the reasonable range you specify (not just
+- 2**32).  If you use a particular compiler version's standard Integer,
who knows if it will be the same 3 CPU generation later when your code is
still in use and you have long since left that project.

A good Ada style guide is
http://www.adaic.org/docs/95style/95style.pdf



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

* Re: unsigned type
  2009-06-28 22:34     ` Gary Scott
  2009-06-28 23:15       ` John B. Matthews
  2009-06-28 23:21       ` anon
@ 2009-06-29  7:18       ` Dmitry A. Kazakov
  2009-06-29  9:52         ` Georg Bauhaus
  2 siblings, 1 reply; 152+ messages in thread
From: Dmitry A. Kazakov @ 2009-06-29  7:18 UTC (permalink / raw)


On Sun, 28 Jun 2009 17:34:29 -0500, Gary Scott wrote:

> tmoran@acm.org wrote:
> 
>> Ada's equivalent is Natural.  If
> 
> Sorry for the naive question.  I'm curious as to the reason for the term 
> "natural".  "Unnatural" would seem more descriptive :)

Far better than Cardinal, though. Last time I used Modula-2, its Cardinal
didn't contain aleph-0 and aleph-1... (:-))

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



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

* Re: unsigned type
  2009-06-29  0:19       ` tmoran
@ 2009-06-29  8:00         ` anon
  2009-06-29  9:56           ` Jean-Pierre Rosen
                             ` (3 more replies)
  0 siblings, 4 replies; 152+ messages in thread
From: anon @ 2009-06-29  8:00 UTC (permalink / raw)


For Strings:
                          --  'A' is a zero length string, A'Last = 0, and
                          --  put_line  ( A ( A'First .. A'Last ) ) ;
                          --  does not raise an Constraint_Error even though in  
                          --  this case it translate to:
                          --  put_line  ( A ( 0 .. 0 ) ) ; 
  A : String := ""        ; 

Since you can have zero length string , the index is Natual instead of Positive, 
because zero is in Natural but is not define in Positive. Even though the 
Standard package define String index as a Positive type. (GNAT)

Always use standards, those who do not are the one making the mistakes 
that others must correct to make the program portable during updating. 
Because the user created type may not be useable on all processor, for 
both backward and upward compatibility. A SUBTYPE might be needed on 
a standard type is always available for upward portable. And a larger 
standard type can be available for backward compatibility.

An example 
  Backward system:  Long_Integer ; -- 32 bit Integer on a 16 bit machine
                       or
                       type Integer is new Long_Integer ; 

  Current system:    Integer ;       -- 32 bit system 

                                      -- limit to 32 bit on a 64 bit system 
  Upward system;    subtype Integer is Standard.Integer 
                                           range (2**32) .. (2**32) -1 ;


  Major rewrite for 128-bit system.


And since the death of PUNCH CARDS there should be no Style, except for 
RPG. This is echoed as hard drives sizes have increase with lower prices. 
And size of the object modules does not change if one uses style or not in 
the source code. Or adds a single line comment or a book length comment 
section. Plus, using the Ada style either 83 or 95 (absent 2005/7) version 
makes the source code unreadable. And also there is no longer any DOD 
requrement to use the Ada Style Guides.

Plus, style is someone's way of creating only one way of programming and 
that might get into patents infringement for all programmers. So, never use 
a predefine style except for your own guidelines.

Finally, most programs will last about 2 CPU generations, before the program 
requires a major rewrite. An example is AT&T original OS, even though one 
can still compile the C version programs, the I/O and driver drivers would 
never works on todays system. Todays hardware is incompatable with the 
older drivers. 

Note: Pentium 1 thru the current Core 2 series are all based on the 6th 
intel generation.

      Core i7 is the 7th Intel generation and is mostly compatibility with 
      Intel 6th generation cpu. And during initial startup or real mode, it 
      is still compatibility with the 8088/8086 series cpu.

      But most 80286/80386 code using protective mode must have a 
      major rewrite if updating to use the Core 2 dual/quad or Core i7.


In <h2919r$8ua$1@aioe.org>, tmoran@acm.org writes:
>> And as for Natural, well, that is the definition of a String's index
>  false.
>> and in most cases you use Naturals in "for loop' statements.
>  false.
>
>> And if you use the standard types instead of creating your own you
>> would save problem when another modifies the program!
>  unlikely.
>
>> Alway use standard if possible,
>  Most experienced Ada programmers would say the opposite.
>
>> That way every program rather Ada or C or etc known the type
>> and the range.
>  false.  I can't count the number of times I had to change a
>program that assumed that, say, the standard type Integer was 32 bits.
>(And almost never was it reasonable for a variable of the type in
>question to have a value of plus or minus a couple of billion.)
>
>> Never create your own types unless lives are an issue.
>  Most Ada programmers would say your programs are more likely to be
>correct if you welcome, rather than refuse, assistance from the compiler.
>If you define your own types, the compiler can check that you aren't
>erroneously adding Number_Of_Apples to Miles_Travelled, and that
>Miles_Travelled is within the reasonable range you specify (not just
>+- 2**32).  If you use a particular compiler version's standard Integer,
>who knows if it will be the same 3 CPU generation later when your code is
>still in use and you have long since left that project.
>
>A good Ada style guide is
>http://www.adaic.org/docs/95style/95style.pdf




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

* Re: unsigned type
  2009-06-28 23:08     ` anon
  2009-06-29  0:19       ` tmoran
@ 2009-06-29  8:42       ` Martin
  2009-06-29  8:54         ` Dmitry A. Kazakov
  1 sibling, 1 reply; 152+ messages in thread
From: Martin @ 2009-06-29  8:42 UTC (permalink / raw)


On Jun 29, 12:08 am, a...@anon.org (anon) wrote:
> And as for Natural, well, that is the definition of a String's index and in most
> cases you use Naturals in "for loop' statements.

Why would you do that?

If you iterating over an array object (e.g. a String), you should use
'Range, e.g.

   for I in My_Array'Range loop
      -- whatever
   end loop;

If you're just looping a certain number of times, you shouldn't need
to say anything about type, e.g.

   for I in 1 .. 10 loop
      -- whatever
   end loop;

Cheers
-- Martin



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

* Re: unsigned type
  2009-06-29  8:42       ` Martin
@ 2009-06-29  8:54         ` Dmitry A. Kazakov
  2009-06-29 10:10           ` Martin
  2009-06-29 19:47           ` anon
  0 siblings, 2 replies; 152+ messages in thread
From: Dmitry A. Kazakov @ 2009-06-29  8:54 UTC (permalink / raw)


On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote:

> On Jun 29, 12:08�am, a...@anon.org (anon) wrote:
>> And as for Natural, well, that is the definition of a String's index and in most
>> cases you use Naturals in "for loop' statements.
> 
> Why would you do that?
> 
> If you iterating over an array object (e.g. a String), you should use
> 'Range, e.g.
> 
>    for I in My_Array'Range loop
>       -- whatever
>    end loop;

Exactly. However there are cases like copying element of one array into
another, when you have to specify the index type explicitly. I always
wished an attribute Index, which for arrays would yield the index subtype
of the array:

   Index : A'Index;

Another issue is shifted views of arrays. E.g. when you get two arrays A
and B, you could bring them to a coherent index range.

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



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

* Re: unsigned type
  2009-06-29  7:18       ` Dmitry A. Kazakov
@ 2009-06-29  9:52         ` Georg Bauhaus
  2009-06-29 12:43           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 152+ messages in thread
From: Georg Bauhaus @ 2009-06-29  9:52 UTC (permalink / raw)


Dmitry A. Kazakov schrieb:
> On Sun, 28 Jun 2009 17:34:29 -0500, Gary Scott wrote:
> 
>> tmoran@acm.org wrote:
>>
>>> Ada's equivalent is Natural.  If
>> Sorry for the naive question.  I'm curious as to the reason for the term 
>> "natural".  "Unnatural" would seem more descriptive :)
> 
> Far better than Cardinal, though. Last time I used Modula-2, its Cardinal
> didn't contain aleph-0 and aleph-1... (:-))
> 

What actually _is_ the mathematically correct word
for Ada's Natural?



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

* Re: unsigned type
  2009-06-29  8:00         ` anon
@ 2009-06-29  9:56           ` Jean-Pierre Rosen
  2009-06-29 10:21             ` Ludovic Brenta
  2009-06-29 20:19             ` anon
  2009-06-29 10:25           ` Georg Bauhaus
                             ` (2 subsequent siblings)
  3 siblings, 2 replies; 152+ messages in thread
From: Jean-Pierre Rosen @ 2009-06-29  9:56 UTC (permalink / raw)


anon a �crit :
> For Strings:
>                           --  'A' is a zero length string, A'Last = 0, and
>                           --  put_line  ( A ( A'First .. A'Last ) ) ;
>                           --  does not raise an Constraint_Error even though in  
>                           --  this case it translate to:
>                           --  put_line  ( A ( 0 .. 0 ) ) ; 
>   A : String := ""        ; 
> 
> Since you can have zero length string , the index is Natual instead of Positive, 
> because zero is in Natural but is not define in Positive. Even though the 
> Standard package define String index as a Positive type. (GNAT)
> 
I usually refrain from responding to "anon", but this is so wrong that I
have to... (Note: in French, "anon" is a young donkey; maybe that's
where he got his name from...)

The index of String is Positive, full stop. A'Last is 0 because null
ranges are treated specially to avoid spurious Constraint_Error. See 3.5(8)
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



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

* Re: unsigned type
  2009-06-29  8:54         ` Dmitry A. Kazakov
@ 2009-06-29 10:10           ` Martin
  2009-06-29 12:34             ` Dmitry A. Kazakov
  2009-06-29 19:26             ` anon
  2009-06-29 19:47           ` anon
  1 sibling, 2 replies; 152+ messages in thread
From: Martin @ 2009-06-29 10:10 UTC (permalink / raw)


On Jun 29, 9:54 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote:
> > On Jun 29, 12:08 am, a...@anon.org (anon) wrote:
> >> And as for Natural, well, that is the definition of a String's index and in most
> >> cases you use Naturals in "for loop' statements.
>
> > Why would you do that?
>
> > If you iterating over an array object (e.g. a String), you should use
> > 'Range, e.g.
>
> >    for I in My_Array'Range loop
> >       -- whatever
> >    end loop;
>
> Exactly. However there are cases like copying element of one array into
> another, when you have to specify the index type explicitly. I always
> wished an attribute Index, which for arrays would yield the index subtype
> of the array:
>
>    Index : A'Index;
>
> Another issue is shifted views of arrays. E.g. when you get two arrays A
> and B, you could bring them to a coherent index range.

True but that hardly fits the billing of "most cases" cited by
'anon'...

Cheers
-- Martin



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

* Re: unsigned type
  2009-06-29  9:56           ` Jean-Pierre Rosen
@ 2009-06-29 10:21             ` Ludovic Brenta
  2009-06-29 11:23               ` sjw
  2009-06-29 19:31               ` anon
  2009-06-29 20:19             ` anon
  1 sibling, 2 replies; 152+ messages in thread
From: Ludovic Brenta @ 2009-06-29 10:21 UTC (permalink / raw)


Jean-Pierre Rosen wrote on comp.lang.ada:
> I usually refrain from responding to "anon", but this is so wrong that I
> have to... (Note: in French, "anon" is a young donkey; maybe that's
> where he got his name from...)

That would explain his stubbornness at using defending top-posting,
too :)

--
Ludovic Brenta.



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

* Re: unsigned type
  2009-06-29  8:00         ` anon
  2009-06-29  9:56           ` Jean-Pierre Rosen
@ 2009-06-29 10:25           ` Georg Bauhaus
  2009-06-29 20:02             ` anon
  2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
  2009-07-11 14:43           ` Hibou57 (Yannick Duchêne)
  3 siblings, 1 reply; 152+ messages in thread
From: Georg Bauhaus @ 2009-06-29 10:25 UTC (permalink / raw)


anon schrieb:
> For Strings:
>                           --  'A' is a zero length string, A'Last = 0, and
>                           --  put_line  ( A ( A'First .. A'Last ) ) ;
>                           --  does not raise an Constraint_Error even though in  
>                           --  this case it translate to:
>                           --  put_line  ( A ( 0 .. 0 ) ) ; 
>   A : String := ""        ; 
> 
> Since you can have zero length string , the index is Natual instead of Positive, 
> because zero is in Natural but is not define in Positive. Even though the 
> Standard package define String index as a Positive type. (GNAT)

(It is slightly confusing, I think, to say that in a
definition like

   type String is array (Positive range <>) of Character;

the index type is Natural. It's not Natural in the Ada sense;
that fact that many String related subprograms use the Natural
subtype emphasizes the presence of Natural in String handling,
but does not turn subtype Positive into index type Natural,
does it?)

> Always use standards, those who do not are the one making the mistakes 
> that others must correct to make the program portable during updating. 

How is it possible for _any_ implementation defined type
to be portable just because the standard says it is
implementation defined? (Like Standard.Integer?)

For example, the GNU Ada Database Environment uses a 64 bit
type available with GNAT.  This type may well be impossible when
using other compilers.

   type SQLBIGINT    is range -(2 ** 63) .. +(2 ** 63) - 1;
   for SQLBIGINT'Size use 64;

How will a subtype of Long_Long_Integer be different?
Long_Long_Integer may not be provided at all. Or it
does not have 64 bits.  I don't see how to gain anything
with subtyping or deriving from the predefined integer
types in cases such as this one.

Using a subtype, there is more opportunity for
shooting yourself in the foot when you use them
where you should have been using database integers.
A more striking example has been outlined by Tom Moran.

Any Ada compiler can immediately decide whether or not this
library unit can be translated (ported) when it sees SQLBIGINT.
Seems perfectly clear, uses standard conforming type definitions,
and explicitly stating what is needed.  Wouldn't this be much
more implicit and more diffuse if the developers had tried to
force database integers to be standard integers?



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

* Re: unsigned type
  2009-06-29 10:21             ` Ludovic Brenta
@ 2009-06-29 11:23               ` sjw
  2009-06-29 12:07                 ` Jean-Pierre Rosen
  2009-06-29 20:06                 ` anon
  2009-06-29 19:31               ` anon
  1 sibling, 2 replies; 152+ messages in thread
From: sjw @ 2009-06-29 11:23 UTC (permalink / raw)


On Jun 29, 11:21 am, Ludovic Brenta <ludo...@ludovic-brenta.org>
wrote:
> Jean-Pierre Rosen wrote on comp.lang.ada:
>
> > I usually refrain from responding to "anon", but this is so wrong that I
> > have to... (Note: in French, "anon" is a young donkey; maybe that's
> > where he got his name from...)
>
> That would explain his stubbornness at using defending top-posting,
> too :)

There is more than one anon@anon.org: recently someone whose alias was
"Anonymous" asked a sensible newbie question, and one of the responses
(not totally daft this time) was from "anon". Google news showed both
email addresses as anon@anon.org ...



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

* Re: unsigned type
  2009-06-29 11:23               ` sjw
@ 2009-06-29 12:07                 ` Jean-Pierre Rosen
  2009-06-29 20:06                 ` anon
  1 sibling, 0 replies; 152+ messages in thread
From: Jean-Pierre Rosen @ 2009-06-29 12:07 UTC (permalink / raw)


sjw a �crit :

> There is more than one anon@anon.org: recently someone whose alias was
> "Anonymous" asked a sensible newbie question, and one of the responses
> (not totally daft this time) was from "anon". Google news showed both
> email addresses as anon@anon.org ...

Hmmm... anon.org has nothing to do with this, it is the site of "Act Now
for Ocean Natives" (i.e., protect the fish)
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



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

* Re: unsigned type
  2009-06-29 10:10           ` Martin
@ 2009-06-29 12:34             ` Dmitry A. Kazakov
  2009-06-29 19:26             ` anon
  1 sibling, 0 replies; 152+ messages in thread
From: Dmitry A. Kazakov @ 2009-06-29 12:34 UTC (permalink / raw)


On Mon, 29 Jun 2009 03:10:31 -0700 (PDT), Martin wrote:

> On Jun 29, 9:54�am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>> On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote:
>>> On Jun 29, 12:08�am, a...@anon.org (anon) wrote:
>>>> And as for Natural, well, that is the definition of a String's index and in most
>>>> cases you use Naturals in "for loop' statements.
>>
>>> Why would you do that?
>>
>>> If you iterating over an array object (e.g. a String), you should use
>>> 'Range, e.g.
>>
>>> � �for I in My_Array'Range loop
>>> � � � -- whatever
>>> � �end loop;
>>
>> Exactly. However there are cases like copying element of one array into
>> another, when you have to specify the index type explicitly. I always
>> wished an attribute Index, which for arrays would yield the index subtype
>> of the array:
>>
>> � �Index : A'Index;
>>
>> Another issue is shifted views of arrays. E.g. when you get two arrays A
>> and B, you could bring them to a coherent index range.
> 
> True but that hardly fits the billing of "most cases" cited by
> 'anon'...

Of course it does not. The rule is strictly opposite to what he says:

Never use a built-in type if you cannot prove that it fits the requirements
and *will* fit them in any observable future.

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



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

* Re: unsigned type
  2009-06-29  9:52         ` Georg Bauhaus
@ 2009-06-29 12:43           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 152+ messages in thread
From: Dmitry A. Kazakov @ 2009-06-29 12:43 UTC (permalink / raw)


On Mon, 29 Jun 2009 11:52:39 +0200, Georg Bauhaus wrote:

> Dmitry A. Kazakov schrieb:
>> On Sun, 28 Jun 2009 17:34:29 -0500, Gary Scott wrote:
>> 
>>> tmoran@acm.org wrote:
>>>
>>>> Ada's equivalent is Natural.  If
>>> Sorry for the naive question.  I'm curious as to the reason for the term 
>>> "natural".  "Unnatural" would seem more descriptive :)
>> 
>> Far better than Cardinal, though. Last time I used Modula-2, its Cardinal
>> didn't contain aleph-0 and aleph-1... (:-))
> 
> What actually _is_ the mathematically correct word
> for Ada's Natural?

I think that "natural" is better than "cardinal". Of course it is not all Z
(natural). It is a subset of Z plus an ideal Constraint_Error to represent
the interval ]Natural'Last..+oo[:

{ 0, 1, 2, ..., Natural'Last, Constraint_Error }

The semantics of Natural operations differs from Z when Constraint_Error is
propagated. Further, there are operations undefined on Z, like
Natural'Size, X'Address etc.

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



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

* Re: unsigned type
  2009-06-28 19:54   ` tmoran
  2009-06-28 22:34     ` Gary Scott
@ 2009-06-29 13:36     ` Rob Solomon
  2009-06-29 14:03       ` Robert A Duff
                         ` (4 more replies)
  1 sibling, 5 replies; 152+ messages in thread
From: Rob Solomon @ 2009-06-29 13:36 UTC (permalink / raw)


I was able to use the Natural and Positive.  

Now I'm trying to understand Mod types.

I tried this:
type card31 is mod 2_147_483_648;
type card32 is mod 4_294_967_296;
c31 : Card31;
c32: Card32;
LI : Long_Integer;
and

LI := Long_Integer(c32);

How to I output c31 and c32?  Modula-2 uses WriteCard or CardToString
and WriteString

I tried using Put, but I got an error saying that correct procedure
could not be found, or something like that.

Put(LI) works until the value of LI > 2**31, even for c32.

Thanks for helping
--rob

On Sun, 28 Jun 2009 19:54:28 +0000 (UTC), tmoran@acm.org wrote:

>>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
>>compiler.  I know Ada does not have a type CARDINAL, but I thought it
>>had a type Unsigned.
>
>Ada's equivalent is Natural.  If
>  Lowest : Natural := 0;
>  Highest : Natural := Natural'last;
>then
>  Lowest  := Lowest-1;  -- will raise an exception
>  Highest := Highest+1; -- ditto
>
>(Note that Gnat by default is not a legal Ada compiler because it doesn't
>check for and raise the exception.  You need a command line parameter
>-gnato to make it act like Ada.)
>
>The standard Ada package Interfaces has hardware-oriented types
>Unsigned_8, Unsigned_16, etc but those are modular types so if
>  Empty_Word : Interfaces.Unsigned_16 := 0;
>  Full_Byte  : Interfaces.Unsigned_8 := 255;
>then
>  Empty_Word-1 will be 65535.
>  Full_Byte+1 will be 0.
>with no exceptions raised.
>
>You can also declare your own application oriented non-negative types
>  type Ratings is range 1 .. 10;
>or modular types
>  type Degrees is mod 360;  -- 0 .. 359 wrapping around



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

* Re: unsigned type
  2009-06-29 13:36     ` Rob Solomon
@ 2009-06-29 14:03       ` Robert A Duff
  2009-06-29 14:13       ` Georg Bauhaus
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 152+ messages in thread
From: Robert A Duff @ 2009-06-29 14:03 UTC (permalink / raw)


Rob Solomon <usenet@drrob1-noreply.com> writes:

> Now I'm trying to understand Mod types.

The first thing to understand is that you should usually avoid
modular types.  ;-)

> I tried this:
> type card31 is mod 2_147_483_648;
> type card32 is mod 4_294_967_296;

You can also say "type T is mod 2**32;".  But take care: it's easy to
think "I want 32 bits, so I'll write 'mod 32'" -- and you get
5 bits.

> c31 : Card31;
> c32: Card32;
> LI : Long_Integer;
> and
>
> LI := Long_Integer(c32);

A type conversion to modular will raise an exception if C32 is too big.
To get around that problem, you should look up the 'Mod attribute.

> How to I output c31 and c32?  Modula-2 uses WriteCard or CardToString
> and WriteString
>
> I tried using Put, but I got an error saying that correct procedure
> could not be found, or something like that.

All scalar types have the 'Image attribute.
Alternatively, you can instantiate the various generic packages
in Text_IO for various scalar types.

- Bob



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

* Re: unsigned type
  2009-06-29 13:36     ` Rob Solomon
  2009-06-29 14:03       ` Robert A Duff
@ 2009-06-29 14:13       ` Georg Bauhaus
  2009-06-29 14:18       ` Ludovic Brenta
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-06-29 14:13 UTC (permalink / raw)


Rob Solomon schrieb:
> I was able to use the Natural and Positive.  
> 
> Now I'm trying to understand Mod types.
> 
> I tried this:
> type card31 is mod 2_147_483_648;
> type card32 is mod 4_294_967_296;
> c31 : Card31;
> c32: Card32;
> LI : Long_Integer;
> and
> 
> LI := Long_Integer(c32);

(this type conversion might not be what you want...)

> How to I output c31 and c32?  Modula-2 uses WriteCard or CardToString
> and WriteString

For the modular types you have defined, you instantiate I/O packages
with the types. For example,

with Ada.Text_IO;  use Ada;  -- make Text_IO directly visible

procedure P is

        type card31 is mod 2_147_483_648;
        type card32 is mod 4_294_967_296;
        c31 : Card31;
        c32: Card32;
        LI : Long_Integer;

	-- I/O of modular numbers defined above
        package Card_IO_31 is new Text_IO.Modular_IO(card31);
        package Card_IO_32 is new Text_IO.Modular_IO(card32);
begin
        Text_IO.put("c31 (not initialized) is ");
        Card_IO_31.Put(c31);
        Text_IO.new_line;

        Text_IO.put("c32 (not initialized) is ");
        Card_IO_32.Put(c32);
        Text_IO.new_line;
end P;

It's usually a good idea to have a tutorial or reference
near you too look up such things.




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

* Re: unsigned type
  2009-06-29 13:36     ` Rob Solomon
  2009-06-29 14:03       ` Robert A Duff
  2009-06-29 14:13       ` Georg Bauhaus
@ 2009-06-29 14:18       ` Ludovic Brenta
  2009-06-29 15:40         ` Robert A Duff
  2009-07-03  1:41         ` Rob Solomon
  2009-06-29 15:37       ` unsigned type Adam Beneschan
  2009-07-06 20:20       ` Dave
  4 siblings, 2 replies; 152+ messages in thread
From: Ludovic Brenta @ 2009-06-29 14:18 UTC (permalink / raw)


Rob Solomon wrote on comp.lang.ada:
> I was able to use the Natural and Positive.  
>
> Now I'm trying to understand Mod types.
>
> I tried this:
> type card31 is mod 2_147_483_648;
> type card32 is mod 4_294_967_296;
> c31 : Card31;
> c32: Card32;
> LI : Long_Integer;
> and
>
> LI := Long_Integer(c32);
>
> How to I output c31 and c32?  Modula-2 uses WriteCard or CardToString
> and WriteString
>
> I tried using Put, but I got an error saying that correct procedure
> could not be found, or something like that.
>
> Put(LI) works until the value of LI > 2**31, even for c32.

Ada.Text_IO.Put_Line (Card31'Image (c31));

or

   package C31_IO is new Ada.Text_IO.Modular_Text_IO (Num => Card31);
begin
   C31_IO.Put (c31);

But I have three suggestions:

- rather than "type card31 is mod 2_147_483_648", write "type card31
is mod 2**31;"

- do not declare machine-oriented types like card31 or card32 in the
first place; instead, define application-oriented types like
"Temperature" or whatever

- before you define modular types, explain to yourself why you need
the wrap-around semantics or the bitwise operators (modular types have
them, signed integer types don't).

--
Ludovic Brenta.



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

* Re: unsigned type
  2009-06-29 13:36     ` Rob Solomon
                         ` (2 preceding siblings ...)
  2009-06-29 14:18       ` Ludovic Brenta
@ 2009-06-29 15:37       ` Adam Beneschan
  2009-07-06 20:20       ` Dave
  4 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-06-29 15:37 UTC (permalink / raw)


On Jun 29, 6:36 am, Rob Solomon <use...@drrob1-noreply.com> wrote:
> I was able to use the Natural and Positive.  
>
> Now I'm trying to understand Mod types.
>
> I tried this:
> type card31 is mod 2_147_483_648;
> type card32 is mod 4_294_967_296;
> c31 : Card31;
> c32: Card32;
> LI : Long_Integer;
> and
>
> LI := Long_Integer(c32);
>
> How to I output c31 and c32?  Modula-2 uses WriteCard or CardToString
> and WriteString
>
> I tried using Put, but I got an error saying that correct procedure
> could not be found, or something like that.
>
> Put(LI) works until the value of LI > 2**31, even for c32.

Ada is a strongly typed language.  "Integer" is a type (defined by the
language); but whenever you declare a new type with a "type" statement
(whether it's a modular type, another signed integer type, or
something else), it will be a new type, and you can't automatically
use values of this new type in places where a value of type Integer is
expected.  The advantage of this is that you can define types for
separate purposes, so that if you declare a real type "Distance" and
another real type "Velocity", for example, you can't accidentally use
a Distance value as a parameter to a procedure that wants a Velocity,
e.g.

The "Put" routine you're using is probably from the
Ada.Integer_Text_IO package; that routine needs an Integer parameter
and won't accept a value of any other type, even another integer
type.  You can create a Put routine that accepts a value of the type
you want by generic instantiation.  For a modular type, an instance of
Ada.Text_IO.Modular_IO (see Georg's post) will create a new package
that has a Put routine with the right parameter type.

The strong typing aspect of Ada is something that trips up a lot of
new Ada programmers, so it's something that I think you do need to
understand.  I don't know Modula-2 so I don't know whether this
concept is already familiar to you.

                                            -- Adam





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

* Re: unsigned type
  2009-06-29 14:18       ` Ludovic Brenta
@ 2009-06-29 15:40         ` Robert A Duff
  2009-07-03  1:41         ` Rob Solomon
  1 sibling, 0 replies; 152+ messages in thread
From: Robert A Duff @ 2009-06-29 15:40 UTC (permalink / raw)


Ludovic Brenta <ludovic@ludovic-brenta.org> writes:

> - before you define modular types, explain to yourself why you need
> the wrap-around semantics...

That's good advice, but there is another reason to use modular types:
you get more positive numbers.  A typical Ada compiler will
support "mod 2**N", but only "range 0..2**(N-1)-1" (where N
is 64 on GNAT, for example).  That's annoying, because you
lose overflow checks.

>...or the bitwise operators (modular types have
> them, signed integer types don't).

Right.  An array of Boolean also has bitwise logical operators
(but not arithmetic).  So for implementing a 'set' as a bit map,
you normally want a packed array of Boolean, whereas in C,
you might use an unsigned type.

- Bob



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

* Re: unsigned type
  2009-06-28 15:36 unsigned type Rob Solomon
                   ` (2 preceding siblings ...)
  2009-06-28 17:56 ` anon
@ 2009-06-29 16:51 ` Martin Krischik
  3 siblings, 0 replies; 152+ messages in thread
From: Martin Krischik @ 2009-06-29 16:51 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rob Solomon schrieb:
> I am trying to learn Ada.  I am very familiar w/ Modula-2.

I have done Modula-2 as well - so I know what you want. And reading all
your other post I think you are on the wrong track. I might be wrong of
course.

Modula-2 is missing one important feature from Pascal: ranges. Ranges is
a different way of thinking. With ranges you don't think about bit and
bytes any more. With ranges you should stop thinking: What is the
largest number one can fit into 32 bit or is CARDINAL large enough for
my need.

Instead you should thing: what is the largest number I truly need. Not
the CPU should be the centre of your thinking but your problem at hand.

i.E.

type Day_Type   is range    1 ..   31;
type Month_Type is range    1 ..   12;
type Year_Type  is range 1800 .. 2100;

type Date_Type is
   record
     Day   : Day_Type;
     Month : Month_Type;
     Year  : Year_Type;
   end record;

Regards

Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKSPD8ijwKaHyem9cRAnQbAKD06jn9yXF9NtaMymDa/EwjpPSoJwCg63to
d52QWtBIkZwzsD0aIBOnzHw=
=JRqC
-----END PGP SIGNATURE-----



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

* Re: unsigned type
  2009-06-29 10:10           ` Martin
  2009-06-29 12:34             ` Dmitry A. Kazakov
@ 2009-06-29 19:26             ` anon
  2009-06-29 23:02               ` Martin
  1 sibling, 1 reply; 152+ messages in thread
From: anon @ 2009-06-29 19:26 UTC (permalink / raw)


        Using Range attribute indexes the entire String or Array and sometime 
an algorithm may need sub-sets. Like instead of spanning  an 1K array the 
algorithm, needs on 9 cells.

        And the 1..10 example you use states that your index is all Natural 
what if you use the "type Color is ( Blue, Green, Red, ... ) ;". 1..10 would 
cause a compiler error. Type is also important. But the compiler will assign 
a scalar values for any enumeration type. And standards suggest that the 
scalar value for the enumeration type begins with zero. 

	Without standards, computer do not work!


In <19faf5c6-1cce-4958-a308-bac61b6ff0eb@r10g2000yqa.googlegroups.com>, Martin <martin.dowie@btopenworld.com> writes:
>On Jun 29, 9:54=A0am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
>wrote:
>> On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote:
>> > On Jun 29, 12:08=A0am, a...@anon.org (anon) wrote:
>> >> And as for Natural, well, that is the definition of a String's index a=
>nd in most
>> >> cases you use Naturals in "for loop' statements.
>>
>> > Why would you do that?
>>
>> > If you iterating over an array object (e.g. a String), you should use
>> > 'Range, e.g.
>>
>> > =A0 =A0for I in My_Array'Range loop
>> > =A0 =A0 =A0 -- whatever
>> > =A0 =A0end loop;
>>
>> Exactly. However there are cases like copying element of one array into
>> another, when you have to specify the index type explicitly. I always
>> wished an attribute Index, which for arrays would yield the index subtype
>> of the array:
>>
>> =A0 =A0Index : A'Index;
>>
>> Another issue is shifted views of arrays. E.g. when you get two arrays A
>> and B, you could bring them to a coherent index range.
>
>True but that hardly fits the billing of "most cases" cited by
>'anon'...
>
>Cheers
>-- Martin




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

* Re: unsigned type
  2009-06-29 10:21             ` Ludovic Brenta
  2009-06-29 11:23               ` sjw
@ 2009-06-29 19:31               ` anon
  2009-06-29 21:49                 ` Georg Bauhaus
       [not found]                 ` <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>
  1 sibling, 2 replies; 152+ messages in thread
From: anon @ 2009-06-29 19:31 UTC (permalink / raw)



        From the APA, or any publishing company, even computer literature 
and etc. All references are at the bottom or back of the chapter/section and 
the main references are always at the back of the book.  Even in GNAT for the 
specification files, the Ada statements are always at the top with the 
comments aka reference can be found below the statement.  This suggest that 
TOP POST is the accepted way of the world and bottom posting is just plain 
backwards.

        The only exception that can be seen in GNAT is the PingPong program 
that is commented at the top of the "GNAT.Sockets" specification package. 
Searching for all of the routines passing all of that dead comments in that 
package it a wonder why people still use "GNAT.Sockets" instead of just 
using "GNAT.Sockets.Thin" all the time.

        I prefer parts of the APA and Adacore way instead of your style 
of bottom posting. More standardized



In <8b44f88e-b56d-4e2d-a0d4-6d4229ce695c@g1g2000yqh.googlegroups.com>, Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>Jean-Pierre Rosen wrote on comp.lang.ada:
>> I usually refrain from responding to "anon", but this is so wrong that I
>> have to... (Note: in French, "anon" is a young donkey; maybe that's
>> where he got his name from...)
>
>That would explain his stubbornness at using defending top-posting,
>too :)
>
>--
>Ludovic Brenta.




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

* Re: unsigned type
  2009-06-29  8:54         ` Dmitry A. Kazakov
  2009-06-29 10:10           ` Martin
@ 2009-06-29 19:47           ` anon
  2009-06-30  8:31             ` Ludovic Brenta
  1 sibling, 1 reply; 152+ messages in thread
From: anon @ 2009-06-29 19:47 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2047 bytes --]

        The use of the "Index" attribute is the type of an example of 
conditional compiling statement, I would prefer to see instead of the 
C-like structure that is in GNAT GPL 2009. The use of the Pre-Processor 
is OK, its an add on package.

        Without Standards, Ada would not exit! And would not be govern 
by the ISO (the International Organization for Standardization) and the 
IEC (the International Electrotechnical Commission).


        Always use Standards. That one of many reason the Standard package 
exist. Its defines those standards. But in teaching Ada, prof allow the 
student to create their own all the time, a bad programming concept.  So, 
the student assume wrongly that they can bypass standards and cause melt 
downs and programming errors. Where standards help prevent those errors. 

        And not using Standards are the main reason the whole world is 
in the mess it is now. And changing to a standard is going to be painful.  
We all should of converted to standard when we first started.


In <g1vm9yf0c339$.12cwzgh82sp3d$.dlg@40tude.net>, "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote:
>
>> On Jun 29, 12:08�am, a...@anon.org (anon) wrote:
>>> And as for Natural, well, that is the definition of a String's index and in most
>>> cases you use Naturals in "for loop' statements.
>> 
>> Why would you do that?
>> 
>> If you iterating over an array object (e.g. a String), you should use
>> 'Range, e.g.
>> 
>>    for I in My_Array'Range loop
>>       -- whatever
>>    end loop;
>
>Exactly. However there are cases like copying element of one array into
>another, when you have to specify the index type explicitly. I always
>wished an attribute Index, which for arrays would yield the index subtype
>of the array:
>
>   Index : A'Index;
>
>Another issue is shifted views of arrays. E.g. when you get two arrays A
>and B, you could bring them to a coherent index range.
>
>-- 
>Regards,
>Dmitry A. Kazakov
>http://www.dmitry-kazakov.de




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

* Re: unsigned type
  2009-06-29 10:25           ` Georg Bauhaus
@ 2009-06-29 20:02             ` anon
  2009-06-29 22:08               ` Georg Bauhaus
  2009-06-30 13:46               ` Jean-Pierre Rosen
  0 siblings, 2 replies; 152+ messages in thread
From: anon @ 2009-06-29 20:02 UTC (permalink / raw)


        As for confusing when the index type is defined as Positive, but the 
compiler and runtime system allows zero.  That's either a compiler Bug or a 
total lack of reading the RM definition of the terms Natural and Positive types 
for Adacore and the GNU GCC Ada maintainers.


        About types and standards. GNU GCC does not work for 16 bit machines 
unless you can find a code developed back in the 1980s. But 8 and 16 bit 
machine are still being use today in special purpose designs. So, code that can 
be develope for those machine are still needed. 

        But using Unsigned_8, Unsigned_16, Unsigned_32 and Unsigned_64 
which are define in the INTERFACE package are true standard because 
Unsigned_8, Unsigned_16, Unsigned_32 and Unsigned_64 do not change rather 
you are using a 8 bit machine or a 64 bit machine or anything in between.

	And Unsigned type is what the person ask about in the first place.

	Always use standards, its is a common ground that allow 
programmers a starting place to understand your code.


In <4a48968a$0$31863$9b4e6d93@newsspool3.arcor-online.net>, Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:
>anon schrieb:
>> For Strings:
>>                           --  'A' is a zero length string, A'Last = 0, and
>>                           --  put_line  ( A ( A'First .. A'Last ) ) ;
>>                           --  does not raise an Constraint_Error even though in  
>>                           --  this case it translate to:
>>                           --  put_line  ( A ( 0 .. 0 ) ) ; 
>>   A : String := ""        ; 
>> 
>> Since you can have zero length string , the index is Natual instead of Positive, 
>> because zero is in Natural but is not define in Positive. Even though the 
>> Standard package define String index as a Positive type. (GNAT)
>
>(It is slightly confusing, I think, to say that in a
>definition like
>
>   type String is array (Positive range <>) of Character;
>
>the index type is Natural. It's not Natural in the Ada sense;
>that fact that many String related subprograms use the Natural
>subtype emphasizes the presence of Natural in String handling,
>but does not turn subtype Positive into index type Natural,
>does it?)
>
>> Always use standards, those who do not are the one making the mistakes 
>> that others must correct to make the program portable during updating. 
>
>How is it possible for _any_ implementation defined type
>to be portable just because the standard says it is
>implementation defined? (Like Standard.Integer?)
>
>For example, the GNU Ada Database Environment uses a 64 bit
>type available with GNAT.  This type may well be impossible when
>using other compilers.
>
>   type SQLBIGINT    is range -(2 ** 63) .. +(2 ** 63) - 1;
>   for SQLBIGINT'Size use 64;
>
>How will a subtype of Long_Long_Integer be different?
>Long_Long_Integer may not be provided at all. Or it
>does not have 64 bits.  I don't see how to gain anything
>with subtyping or deriving from the predefined integer
>types in cases such as this one.
>
>Using a subtype, there is more opportunity for
>shooting yourself in the foot when you use them
>where you should have been using database integers.
>A more striking example has been outlined by Tom Moran.
>
>Any Ada compiler can immediately decide whether or not this
>library unit can be translated (ported) when it sees SQLBIGINT.
>Seems perfectly clear, uses standard conforming type definitions,
>and explicitly stating what is needed.  Wouldn't this be much
>more implicit and more diffuse if the developers had tried to
>force database integers to be standard integers?




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

* Re: unsigned type
  2009-06-29 11:23               ` sjw
  2009-06-29 12:07                 ` Jean-Pierre Rosen
@ 2009-06-29 20:06                 ` anon
  1 sibling, 0 replies; 152+ messages in thread
From: anon @ 2009-06-29 20:06 UTC (permalink / raw)


        TOTALLY WRONG!!!  If you check the writing style of "anon@anon.org 
(anon)" you will see that there is one and only one person that uses that 
name and post at the movement from ATT.NET. Of course, if a few weeks 
that will change.

        The other person who spelled out "Anonymous" just copyed the email 
address that I use.  If you look I did answer his question, but I assume 
that person installed the correct version aka the 64-bit version.  And 
under Linux I prefer "Kate" instead of the GPS ide, faster and fexible 
for my needs.


In <36be81a3-2a1b-442e-a404-13ad2c94cb7c@z9g2000yqi.googlegroups.com>, sjw <simon.j.wright@mac.com> writes:
>On Jun 29, 11:21=A0am, Ludovic Brenta <ludo...@ludovic-brenta.org>
>wrote:
>> Jean-Pierre Rosen wrote on comp.lang.ada:
>>
>> > I usually refrain from responding to "anon", but this is so wrong that =
>I
>> > have to... (Note: in French, "anon" is a young donkey; maybe that's
>> > where he got his name from...)
>>
>> That would explain his stubbornness at using defending top-posting,
>> too :)
>
>There is more than one anon@anon.org: recently someone whose alias was
>"Anonymous" asked a sensible newbie question, and one of the responses
>(not totally daft this time) was from "anon". Google news showed both
>email addresses as anon@anon.org ...




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

* Re: unsigned type
  2009-06-29  9:56           ` Jean-Pierre Rosen
  2009-06-29 10:21             ` Ludovic Brenta
@ 2009-06-29 20:19             ` anon
  2009-06-29 20:41               ` Ludovic Brenta
                                 ` (4 more replies)
  1 sibling, 5 replies; 152+ messages in thread
From: anon @ 2009-06-29 20:19 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]


        Wrong re-read RM 3.5 (8) An Empty string may be a "Null range" string 
but zero ( 0 ) is not within the subtype of the Positive type. The second 
sentence of RM 3.5 ( 8 ) forces the index to be valid for all references 
including a null range statement.  Also, as I pointed out to Adam, about 
"Ada.Command_line" there may be other sections that may strengthen or may 
redefine RM 3.5 ( 8 ). 

        A : String ;
        ...
        A ( 1..1 ) -- is a valid string with a null range also equal 
                   -- to character reference of A ( 1 )  

        A ( 0..0 ) -- is not valid because the index range is not within 
                   -- the valid range of the subtype Postive. 
                   -- And at least the compiler should of trap the error.
                   -- Or is this a Compiler Bug!
  
RM 3.5
8   A range is compatible with a scalar subtype if and only if it is either a
null range or each bound of the range belongs to the range of the subtype.  A
range_constraint is compatible with a scalar subtype if and only if its range
is compatible with the subtype.


        And name calling show just how childless you are.



In <t43a2h.upd.ln@hunter.axlog.fr>, Jean-Pierre Rosen <rosen@adalog.fr> writes:
>anon a �crit :
>> For Strings:
>>                           --  'A' is a zero length string, A'Last = 0, and
>>                           --  put_line  ( A ( A'First .. A'Last ) ) ;
>>                           --  does not raise an Constraint_Error even though in  
>>                           --  this case it translate to:
>>                           --  put_line  ( A ( 0 .. 0 ) ) ; 
>>   A : String := ""        ; 
>> 
>> Since you can have zero length string , the index is Natual instead of Positive, 
>> because zero is in Natural but is not define in Positive. Even though the 
>> Standard package define String index as a Positive type. (GNAT)
>> 
>I usually refrain from responding to "anon", but this is so wrong that I
>have to... (Note: in French, "anon" is a young donkey; maybe that's
>where he got his name from...)
>
>The index of String is Positive, full stop. A'Last is 0 because null
>ranges are treated specially to avoid spurious Constraint_Error. See 3.5(8)
>-- 
>---------------------------------------------------------
>           J-P. Rosen (rosen@adalog.fr)
>Visit Adalog's web site at http://www.adalog.fr




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

* Re: unsigned type
  2009-06-29 20:19             ` anon
@ 2009-06-29 20:41               ` Ludovic Brenta
  2009-06-29 22:15               ` Georg Bauhaus
                                 ` (3 subsequent siblings)
  4 siblings, 0 replies; 152+ messages in thread
From: Ludovic Brenta @ 2009-06-29 20:41 UTC (permalink / raw)


On Jun 29, 10:19 pm, a...@anon.org (anon) wrote:
>         Wrong re-read RM 3.5 (8)
[...]

You should perhaps pay attention who you're talking to. Jean-Pierre is
a member of the ARG, the group that *wrote* the RM.

[...]

>         And name calling show just how childless you are.

Jean-Pierre have children, one of whom I know personally, so there you
are wrong again.

--
Ludovic Brenta.



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

* Re: unsigned type
  2009-06-29 19:31               ` anon
@ 2009-06-29 21:49                 ` Georg Bauhaus
       [not found]                 ` <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>
  1 sibling, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-06-29 21:49 UTC (permalink / raw)


anon wrote:
 [regarding top posting]
>         From the APA, or any publishing company, even computer literature 
> and etc. All references are at the bottom or back of the chapter/section and 
> the main references are always at the back of the book.


The style you mention ("top posting@, everything else in notes
or parens) is adequate when typical highfalutin publication
rules do matter;  I'd consider usenet postings much closer
to the more spontaneous work done *before* you publish a paper
that respects traditional formal outfit: others discuss it
with you, and/or read it armed with pencils.

To me, usenet means "it'll be very kind if you pick up a red
pen and mark my errors. Also you'll likely be doing us a favor
if you write some annotations next to what I have written".

For this style of "immediate" text work, chopping the
original and injecting remarks hat merits, I think.



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

* Re: unsigned type
  2009-06-29 20:02             ` anon
@ 2009-06-29 22:08               ` Georg Bauhaus
  2009-06-30 23:01                 ` Randy Brukardt
  2009-06-30 13:46               ` Jean-Pierre Rosen
  1 sibling, 1 reply; 152+ messages in thread
From: Georg Bauhaus @ 2009-06-29 22:08 UTC (permalink / raw)


anon wrote:
>         As for confusing when the index type is defined as Positive, but the 
> compiler and runtime system allows zero.  That's either a compiler Bug or a 
> total lack of reading the RM definition of the terms Natural and Positive types 
> for Adacore and the GNU GCC Ada maintainers.

Neither is true, see the hint and reference by J.-P. Rosen
in a response to your claim.

>         About types and standards. GNU GCC does not work for 16 bit machines 
> unless you can find a code developed back in the 1980s. But 8 and 16 bit 
> machine are still being use today in special purpose designs. So, code that can 
> be develope for those machine are still needed. 

How does the machine affect a type definition such as

   type N is range 1 .. 10_000_000;

If a compiler produces code for an 8bit �Controller
then it is still free to support 16bit size integers
and 32bit size integers, or Unsigned_N where N /= 8.
I see no vagueness here.

In fact, for Janus/Ada, where Integer is a 16bit type,
the announcement states, "Support for full 16 and 32-bit
unsigned types and their operations is included"...

Hence, if you relied on standard integer types,
you might be running into surprises that could have
been avoided by clearly defining your own integer
types, whether they start at 0 or not.


>         But using Unsigned_8, Unsigned_16, Unsigned_32 and Unsigned_64 
> which are define in the INTERFACE package are true standard because 
> Unsigned_8, Unsigned_16, Unsigned_32 and Unsigned_64 do not change rather 
> you are using a 8 bit machine or a 64 bit machine or anything in between.

The type definition

  type N is range 1 .. 10_000_000;

not only does not change, but the objects created will be
created by a smart compiler, not by a smart programmer
who thinks, it seems, too much about Unsigned_N where
it simply does not matter, technically.

> 	And Unsigned type is what the person ask about in the first place.

Not everyone agrees.



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

* Re: unsigned type
  2009-06-29 20:19             ` anon
  2009-06-29 20:41               ` Ludovic Brenta
@ 2009-06-29 22:15               ` Georg Bauhaus
  2009-06-29 23:08               ` Adam Beneschan
                                 ` (2 subsequent siblings)
  4 siblings, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-06-29 22:15 UTC (permalink / raw)


anon wrote:
>         Wrong

No.  If authors of the current RM can't convince you,
maybe a quote from the Ada 83 edition can:

"no value belongs to a null range" (Ada 83 RM 3.5)

with all consequences...



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

* Re: unsigned type
  2009-06-29 19:26             ` anon
@ 2009-06-29 23:02               ` Martin
  0 siblings, 0 replies; 152+ messages in thread
From: Martin @ 2009-06-29 23:02 UTC (permalink / raw)


On Jun 29, 8:26 pm, a...@anon.org (anon) wrote:
>         Using Range attribute indexes the entire String or Array and sometime
> an algorithm may need sub-sets. Like instead of spanning  an 1K array the
> algorithm, needs on 9 cells.

'sometime' /= 'most cases'...

...'most cases' is almost certainly Object'Range. I don't have access
to all the Ada source ever written, so I can't say that with 100%
certainty but I do know what makes up 'most cases' in the code I
write.


>         And the 1..10 example you use states that your index is all Natural
> what if you use the "type Color is ( Blue, Green, Red, ... ) ;". 1..10 would
> cause a compiler error. Type is also important.

Did you actually read what I wrote? The '1 .. 10' example was for when
needed to iterate a 'certain number of times' - nothing involving
abstract concepts like 'iterator for each colour'. If I wanted to do
that then fine, use:

   for C in Colour_Type loop
      -- whatever
   end loop;

_unless_ your iterating over an array indexed by Colour_Type in which
case the preferred style is,

   for C in Array_Indexed_By_Colour'Range loop
      -- whatever
   end loop;


> But the compiler will assign
> a scalar values for any enumeration type. And standards suggest that the
> scalar value for the enumeration type begins with zero.
>
>         Without standards, computer do not work!

See above - it was nothing about enumerations.


> In <19faf5c6-1cce-4958-a308-bac61b6ff...@r10g2000yqa.googlegroups.com>, Martin <martin.do...@btopenworld.com> writes:
>
> >On Jun 29, 9:54=A0am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> >wrote:
> >> On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote:
> >> > On Jun 29, 12:08=A0am, a...@anon.org (anon) wrote:
> >> >> And as for Natural, well, that is the definition of a String's index a=
> >nd in most
> >> >> cases you use Naturals in "for loop' statements.
>
> >> > Why would you do that?
>
> >> > If you iterating over an array object (e.g. a String), you should use
> >> > 'Range, e.g.
>
> >> > =A0 =A0for I in My_Array'Range loop
> >> > =A0 =A0 =A0 -- whatever
> >> > =A0 =A0end loop;
>
> >> Exactly. However there are cases like copying element of one array into
> >> another, when you have to specify the index type explicitly. I always
> >> wished an attribute Index, which for arrays would yield the index subtype
> >> of the array:
>
> >> =A0 =A0Index : A'Index;
>
> >> Another issue is shifted views of arrays. E.g. when you get two arrays A
> >> and B, you could bring them to a coherent index range.
>
> >True but that hardly fits the billing of "most cases" cited by
> >'anon'...
>
> >Cheers
> >-- Martin
>
>




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

* Re: unsigned type
  2009-06-29 20:19             ` anon
  2009-06-29 20:41               ` Ludovic Brenta
  2009-06-29 22:15               ` Georg Bauhaus
@ 2009-06-29 23:08               ` Adam Beneschan
  2009-06-29 23:11               ` Adam Beneschan
  2009-06-30 12:39               ` Martin
  4 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-06-29 23:08 UTC (permalink / raw)


On Jun 29, 1:19 pm, a...@anon.org (anon) wrote:
>         Wrong re-read RM 3.5 (8) An Empty string may be a "Null range" string
> but zero ( 0 ) is not within the subtype of the Positive type. The second
> sentence of RM 3.5 ( 8 ) forces the index to be valid for all references
> including a null range statement.

Excuse me?  The first sentence of 3.5(8) tells you when a "range is
compatible".  (And it says that a null range is compatible even if its
bounds don't belong to the subtype.)  The second sentence says "A
range_constraint is compatible... if and only if its range is
compatible...".  Thus the second sentence refers to the definition
given in the first sentence, so how can the second sentence impose a
requirement that the first sentence doesn't???

                          -- Adam



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

* Re: unsigned type
  2009-06-29 20:19             ` anon
                                 ` (2 preceding siblings ...)
  2009-06-29 23:08               ` Adam Beneschan
@ 2009-06-29 23:11               ` Adam Beneschan
  2009-06-30 12:39               ` Martin
  4 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-06-29 23:11 UTC (permalink / raw)


And furthermore...

On Jun 29, 1:19 pm, a...@anon.org (anon) wrote:
>         A : String ;
>         ...
>         A ( 1..1 ) -- is a valid string with a null range also equal
>                    -- to character reference of A ( 1 )  

I wish I had read on before my previous response, or I would have
responded to this also...  A(1..1) is a slice with one component, so
how can 1..1 be a "null range"?  Read 3.5(4).  L..R is a null range if
R is less than L; is 1 now less than 1?

                              -- Adam



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

* Re: unsigned type
  2009-06-29 19:47           ` anon
@ 2009-06-30  8:31             ` Ludovic Brenta
  0 siblings, 0 replies; 152+ messages in thread
From: Ludovic Brenta @ 2009-06-30  8:31 UTC (permalink / raw)


anon wrote on comp.lang.ada:
>         Always use Standards. That one of many reason the Standard package
> exist. Its defines those standards. But in teaching Ada, prof allow the
> student to create their own all the time, a bad programming concept.  So,
> the student assume wrongly that they can bypass standards and cause melt
> downs and programming errors. Where standards help prevent those errors.

Are you trying to suggest that user-defined types are not part of the
Ada standard? Then can you explain why you think RM 3.2.1 is not part
of the standard?

--
Ludovic Brenta.



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

* Re: unsigned type
       [not found]                 ` <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>
@ 2009-06-30 11:29                   ` anon
  2009-06-30 12:19                     ` Ludovic Brenta
  0 siblings, 1 reply; 152+ messages in thread
From: anon @ 2009-06-30 11:29 UTC (permalink / raw)


First since a few RFC have been replaced or updated has this one. 

But in looking at the RFC that you posted where are the others' "summarizes 
the original" message, no one does that. And most include the complete 
message which goes against the "do not include the entire original".

And the RFC also says "it is possible to see a response to a message before 
seeing the original." This is allowed and its also called "top posting". So I 
am, in this case following the rules of the RFC, but no one else to follow any 
part of RFC 1855, section 3.1.1.


In <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>, Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
>On Mon, 29 Jun 2009 19:31:16 GMT, anon@anon.org (anon) declaimed the
>following in comp.lang.ada:
>
>
>>         I prefer parts of the APA and Adacore way instead of your style 
>> of bottom posting. More standardized
>>
>	I suppose then that you prefer to ignore Internet RFCs...
>
>RFC 1855, section 3.1.1 -- I'm going to just cut&paste one bullet:
>
>"""
> - If you are sending a reply to a message or a posting be sure you
>      summarize the original at the top of the message, or include just
>      enough text of the original to give a context.  This will make
>      sure readers understand when they start to read your response.
>      Since NetNews, especially, is proliferated by distributing the
>      postings from one host to another, it is possible to see a
>      response to a message before seeing the original.  Giving context
>      helps everyone.  But do not include the entire original!
>"""
>
>	For one-to-one email, where the recipient is presumed familiar with
>the quoted material, top posting may be permissible; the quoted material
>then acts as a photocopy enclosure -- though I'd prefer not to see it
>all if one is not trimming/interspersing comments; if one is replying to
>a personal message I sent, /I/ already have a copy of the message and
>can look it up.
>
>-- 
>	Wulfraed	Dennis Lee Bieber		KD6MOG
>	wlfraed@ix.netcom.com		wulfraed@bestiaria.com
>		HTTP://wlfraed.home.netcom.com/
>	(Bestiaria Support Staff:		web-asst@bestiaria.com)
>		HTTP://www.bestiaria.com/




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

* Re: unsigned type
  2009-06-30 11:29                   ` anon
@ 2009-06-30 12:19                     ` Ludovic Brenta
  0 siblings, 0 replies; 152+ messages in thread
From: Ludovic Brenta @ 2009-06-30 12:19 UTC (permalink / raw)


anon top-posted on comp.lang.ada:
[about RFC 1855]
> First since a few RFC have been replaced or updated has this one.

No, it hasn't, TTBOMK.

> But in looking at the RFC that you posted where are the others' "summarizes
> the original" message, no one does that.

Wrong. In this very thread you just ignored two people who did
summarize: Dennis (to whom you were responding, no less) and myself,
who routinely summarizes the posts I respond to.

> And most include the complete
> message which goes against the "do not include the entire original".

Wrong. Even if your perception were right, just because "most" include
the complete message doesn't mean you should do the same mistake,
too.  This I call the "lemming argument".  By your own "lemming
argument", you should be programming in Visual Basic on Windows, or in
COBOL on a mainframe.

> And the RFC also says "it is possible to see a response to a message before
> seeing the original." This is allowed and its also called "top posting". So I
> am, in this case following the rules of the RFC, but no one else to follow any
> part of RFC 1855, section 3.1.1.

Wrong. You did not understand the RFC.  The "response" and the
"original message" in the sentence are two different posts.  It is
indeed possible that you see the second post containing the response
before the first post containing the question.   The RFC does not
endorse top-posting; in fact it specifically recommends against it.

--
Ludovic Brenta.



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

* Re: unsigned type
  2009-06-29 20:19             ` anon
                                 ` (3 preceding siblings ...)
  2009-06-29 23:11               ` Adam Beneschan
@ 2009-06-30 12:39               ` Martin
  4 siblings, 0 replies; 152+ messages in thread
From: Martin @ 2009-06-30 12:39 UTC (permalink / raw)


On Jun 29, 9:19 pm, a...@anon.org (anon) wrote:
[snip]
>         A : String ;

Compilation error - String is an unconstrained type.

>         A ( 1..1 ) -- is a valid string with a null range also equal
>                    -- to character reference of A ( 1 )  

This isn't a null range...it's a range with a length of 1.

If you want a null String, use:

   A : String := "";

Cheers
-- Martin



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

* Re: unsigned type
  2009-06-29 20:02             ` anon
  2009-06-29 22:08               ` Georg Bauhaus
@ 2009-06-30 13:46               ` Jean-Pierre Rosen
  2009-06-30 15:22                 ` Adam Beneschan
  1 sibling, 1 reply; 152+ messages in thread
From: Jean-Pierre Rosen @ 2009-06-30 13:46 UTC (permalink / raw)


anon a �crit :
>         As for confusing when the index type is defined as Positive, but the 
> compiler and runtime system allows zero.  That's either a compiler Bug or a 
> total lack of reading the RM definition of the terms Natural and Positive types 
> for Adacore and the GNU GCC Ada maintainers.
> 

The idea is that you don't check that bounds belong to the index subtype
if the range is null (i.e., all null ranges are allowed). This is
intended to avoid raising constraint_error if you declare a String(1..0)
Note that it makes code generation for aggregates much more complicated
in some cases - and I wrote the code generator for array aggregates in
Ada-Ed v2, long ago.

So it is not a bug, it doesn't prove that the index is natural, it's
just the intended behaviour, designed in a way that makes user's life
easier - at the cost of compiler writers' life.
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



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

* Re: unsigned type
  2009-06-30 13:46               ` Jean-Pierre Rosen
@ 2009-06-30 15:22                 ` Adam Beneschan
  2009-06-30 15:59                   ` Albrecht Käfer
  2009-07-01  8:09                   ` Jean-Pierre Rosen
  0 siblings, 2 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-06-30 15:22 UTC (permalink / raw)


On Jun 30, 6:46 am, Jean-Pierre Rosen <ro...@adalog.fr> wrote:

> So it is not a bug, it doesn't prove that the index is natural, it's
> just the intended behaviour, designed in a way that makes user's life
> easier - at the cost of compiler writers' life.

As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
LITERALLY!!!!!!!

                        -- Adam




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

* Re: unsigned type
  2009-06-30 15:22                 ` Adam Beneschan
@ 2009-06-30 15:59                   ` Albrecht Käfer
  2009-06-30 16:59                     ` Adam Beneschan
  2009-07-01  8:09                   ` Jean-Pierre Rosen
  1 sibling, 1 reply; 152+ messages in thread
From: Albrecht Käfer @ 2009-06-30 15:59 UTC (permalink / raw)


Adam Beneschan schrieb:
>> So it is not a bug, it doesn't prove that the index is natural, it's
>> just the intended behaviour, designed in a way that makes user's life
>> easier - at the cost of compiler writers' life.
>
> As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
> LITERALLY!!!!!!!

From what I gathered, this seems to be an important part of the Ada
philosophy. Probably the best example is tasking.


Albrecht



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

* Re: unsigned type
  2009-06-30 15:59                   ` Albrecht Käfer
@ 2009-06-30 16:59                     ` Adam Beneschan
  2009-06-30 17:44                       ` Albrecht Käfer
  2009-06-30 23:48                       ` anon
  0 siblings, 2 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-06-30 16:59 UTC (permalink / raw)


On Jun 30, 8:59 am, Albrecht Käfer <albrecht_kae...@yahoo.de> wrote:
> Adam Beneschan schrieb:
>
> >> So it is not a bug, it doesn't prove that the index is natural, it's
> >> just the intended behaviour, designed in a way that makes user's life
> >> easier - at the cost of compiler writers' life.
>
> > As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
> > LITERALLY!!!!!!!
>
> From what I gathered, this seems to be an important part of the Ada
> philosophy.

It's an important part of the Ada philosophy that working on writing
an Ada compiler will cost you your life?

> Probably the best example is tasking.

OK, maybe that *is* a good example.  I've worked on tasking.... But
I'm not quite dead yet, and I might still be able to pull through.
(Depending on what changes the ARG may make to 3.10.2...)

                                -- Adam




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

* Re: unsigned type
  2009-06-30 16:59                     ` Adam Beneschan
@ 2009-06-30 17:44                       ` Albrecht Käfer
  2009-06-30 18:13                         ` Robert A Duff
  2009-06-30 23:48                       ` anon
  1 sibling, 1 reply; 152+ messages in thread
From: Albrecht Käfer @ 2009-06-30 17:44 UTC (permalink / raw)


Adam Beneschan schrieb:
>> >> So it is not a bug, it doesn't prove that the index is natural, it's
>> >> just the intended behaviour, designed in a way that makes user's life
>> >> easier - at the cost of compiler writers' life.
>> > As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
>> > LITERALLY!!!!!!!
>> From what I gathered, this seems to be an important part of the Ada
>> philosophy.
> It's an important part of the Ada philosophy that working on writing
> an Ada compiler will cost you your life?

Well, maybe not that drastic. But unlike C, it should be easier to write
a Ada program than to write an Ada compiler.


Albrecht



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

* Re: unsigned type
  2009-06-30 17:44                       ` Albrecht Käfer
@ 2009-06-30 18:13                         ` Robert A Duff
  2009-06-30 18:16                           ` Albrecht Käfer
  0 siblings, 1 reply; 152+ messages in thread
From: Robert A Duff @ 2009-06-30 18:13 UTC (permalink / raw)


Albrecht K�fer <albrecht_kaefer@yahoo.de> writes:

> Well, maybe not that drastic. But unlike C, it should be easier to write
> a Ada program than to write an Ada compiler.

I get paid to write an Ada program that IS an Ada compiler.  ;-)

- Bob



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

* Re: unsigned type
  2009-06-30 18:13                         ` Robert A Duff
@ 2009-06-30 18:16                           ` Albrecht Käfer
  0 siblings, 0 replies; 152+ messages in thread
From: Albrecht Käfer @ 2009-06-30 18:16 UTC (permalink / raw)


Robert A Duff schrieb:
>> Well, maybe not that drastic. But unlike C, it should be easier to write
>> a Ada program than to write an Ada compiler.
> I get paid to write an Ada program that IS an Ada compiler.  ;-)

Just imagine if you had to write it in C!


Albrecht



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

* Re: unsigned type
  2009-06-29 22:08               ` Georg Bauhaus
@ 2009-06-30 23:01                 ` Randy Brukardt
  0 siblings, 0 replies; 152+ messages in thread
From: Randy Brukardt @ 2009-06-30 23:01 UTC (permalink / raw)


"Georg Bauhaus" <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> wrote in 
message news:4a493b54$0$31879$9b4e6d93@newsspool3.arcor-online.net...
...
> In fact, for Janus/Ada, where Integer is a 16bit type,
> the announcement states, "Support for full 16 and 32-bit
> unsigned types and their operations is included"...

It's interesting that the primary reason that we didn't change type Integer 
from 16-bit to 32-bit when we moved the compiler to the 386 was because we 
had (and our customers had) too much old code that failed to follow the 
advice to avoid using the predefined types. And a lot of that code assumed a 
16-bit representation.

Moral of the story: if you care about portability, limit as much as possible 
the use of the numeric types defined in Standard.

                                               Randy.







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

* Re: unsigned type
  2009-06-30 16:59                     ` Adam Beneschan
  2009-06-30 17:44                       ` Albrecht Käfer
@ 2009-06-30 23:48                       ` anon
  2009-07-01  1:39                         ` Adam Beneschan
  1 sibling, 1 reply; 152+ messages in thread
From: anon @ 2009-06-30 23:48 UTC (permalink / raw)


Read RM 3.5  ( 4 )

Is "A ( 0 .. 0 )" an example of null range.  By the definition in RM 3.5 
( 4 ), the Right side range (index) must be less than the Left side, so 
"A ( 0.. 0 )" is not a valid null range statement. So, this statement 
should generate a compiler or runtime error, because either range is not 
a subset of the range for Strings.


Reference:  RM 3.5 Scalar Types 

4   A range has a lower bound and an upper bound and specifies a subset of
the values of some scalar type (the type of the range).  A range with lower
bound L and upper bound R is described by ``L .. R''.  If R is less than L,
                                                       ^^^^^^^^^^^^^^^^^^^^
then the range is a null range, and specifies an empty set of values.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Otherwise, the range specifies the values of the type from the lower bound to
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the upper bound, inclusive.  A value belongs to a range if it is of the type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
of the range, and is in the subset of values specified by the range.  A value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
satisfies a range constraint if it belongs to the associated range.  One
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
range is included in another if all values that belong to the first range
also belong to the second.



In <d8789140-eb5e-4f1d-b5ad-65df3db609cf@s6g2000vbp.googlegroups.com>, Adam Beneschan <adam@irvine.com> writes:
>On Jun 30, 8:59=A0am, Albrecht K=E4fer <albrecht_kae...@yahoo.de> wrote:
>> Adam Beneschan schrieb:
>>
>> >> So it is not a bug, it doesn't prove that the index is natural, it's
>> >> just the intended behaviour, designed in a way that makes user's life
>> >> easier - at the cost of compiler writers' life.
>>
>> > As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
>> > LITERALLY!!!!!!!
>>
>> From what I gathered, this seems to be an important part of the Ada
>> philosophy.
>
>It's an important part of the Ada philosophy that working on writing
>an Ada compiler will cost you your life?
>
>> Probably the best example is tasking.
>
>OK, maybe that *is* a good example.  I've worked on tasking.... But
>I'm not quite dead yet, and I might still be able to pull through.
>(Depending on what changes the ARG may make to 3.10.2...)
>
>                                -- Adam
>




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

* Re: unsigned type
  2009-06-30 23:48                       ` anon
@ 2009-07-01  1:39                         ` Adam Beneschan
  2009-07-02 19:04                           ` anon
  2009-07-02 19:49                           ` anon
  0 siblings, 2 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-07-01  1:39 UTC (permalink / raw)


On Jun 30, 4:48 pm, a...@anon.org (anon) wrote:
> Read RM 3.5  ( 4 )
>
> Is "A ( 0 .. 0 )" an example of null range.  By the definition in RM 3.5
> ( 4 ), the Right side range (index) must be less than the Left side, so
> "A ( 0.. 0 )" is not a valid null range statement. So, this statement
> should generate a compiler or runtime error, because either range is not
> a subset of the range for Strings.

OK, I think I've finally figured out why we're having this confusing
argument.  It goes way back to this post of yours:

>> For Strings:
>>                          --  'A' is a zero length string, A'Last = 0, and
>>                          --  put_line  ( A ( A'First .. A'Last ) ) ;
>>                          --  does not raise an Constraint_Error even though in
>>                          --  this case it translate to:
>>                          --  put_line  ( A ( 0 .. 0 ) ) ;
>>  A : String := ""        ;

It does not translate to A (0..0); it translates to A (1..0).  If A is
declared as in your example above, A'First will be 1 and A'Last will
be 0.  Try it (try declaring A like that and outputting A'First and
A'Last).  It looks like everyone else missed this original error of
yours, which has apparently led to some confusion.

In this case, A'First..A'Last, which is 1..0, is compatible with the
subtype because it's a null range, and null ranges are compatible with
the subtype even when the range bounds don't actually belong to the
subtype.  0..0 is not compatible with the subtype, but you cannot
declare a string with that index range unless you try to do it
explicitly:

   A : String (0..0);

and then you *will* get a Constraint_Error.

So your later assertion that follows:

>> Since you can have zero length string , the index is Natual instead of Positive,
>> because zero is in Natural but is not define in Positive. Even though the
>> Standard package define String index as a Positive type. (GNAT)

is wrong.  The index range is Positive, but null ranges don't have to
meet that constraint.  They don't have to be Natural, either.  This is
legal and will not raise an exception at runtime:

   B : String (-9 .. -10) := "";

Hope this clears everything up.

                                  -- Adam




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

* Re: unsigned type
  2009-06-30 15:22                 ` Adam Beneschan
  2009-06-30 15:59                   ` Albrecht Käfer
@ 2009-07-01  8:09                   ` Jean-Pierre Rosen
  2009-07-01 15:08                     ` Albrecht Käfer
  1 sibling, 1 reply; 152+ messages in thread
From: Jean-Pierre Rosen @ 2009-07-01  8:09 UTC (permalink / raw)


Adam Beneschan a �crit :
> On Jun 30, 6:46 am, Jean-Pierre Rosen <ro...@adalog.fr> wrote:
> 
>> So it is not a bug, it doesn't prove that the index is natural, it's
>> just the intended behaviour, designed in a way that makes user's life
>> easier - at the cost of compiler writers' life.
> 
> As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
> LITERALLY!!!!!!!
> 
>                         -- Adam
> 
Well, it is a shorthand for "at the cost of making the compiler writer's
life easier". That's what you get for being lazy :-)

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



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

* Re: unsigned type
  2009-07-01  8:09                   ` Jean-Pierre Rosen
@ 2009-07-01 15:08                     ` Albrecht Käfer
  0 siblings, 0 replies; 152+ messages in thread
From: Albrecht Käfer @ 2009-07-01 15:08 UTC (permalink / raw)


Jean-Pierre Rosen schrieb:
>>> So it is not a bug, it doesn't prove that the index is natural, it's
>>> just the intended behaviour, designed in a way that makes user's life
>>> easier - at the cost of compiler writers' life.
>> As a compiler writer, PLEASE TELL ME YOU DIDN'T MEAN THAT LAST PART
>> LITERALLY!!!!!!!
> Well, it is a shorthand for "at the cost of making the compiler writer's
> life easier". That's what you get for being lazy :-)

*blush*
Now I get it. The way some people interpret things ...


Albrecht



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

* Re: unsigned type
  2009-07-01  1:39                         ` Adam Beneschan
@ 2009-07-02 19:04                           ` anon
  2009-07-02 19:49                           ` anon
  1 sibling, 0 replies; 152+ messages in thread
From: anon @ 2009-07-02 19:04 UTC (permalink / raw)


Adam. 
 
RM 3.6.1 ( 17..18 ) proves your point about strings with subscripts of ( 1..0 ). 
But it kinds of flys in the face of RM 0 ( 29 ) [ see below ]. Since we must use the keyword "reverse" to transverse a loop index 
in deceasing order, it would seam logical that ( 1 .. 0 ) or S ( S'First .. ( S'First - 1 ) ) 
should be illegal for Strings because the 0 is not within the range of the 
predefined type Positive. But a String with length greater than 1 the we could 
use: S ( ( S'First + 1 ) .. S'First ) => S ( 2 ..1 ) would be legal because 
both index values are legal subscripts and these values could be all the 
way to S ( S'Last .. S'First ) to get a null array (String).
 
 
Note : Around line 291 of RM 95 Text version

RM  0. (29) 
29   Execution of a program unit may encounter error situations in which
normal program execution cannot continue.  For example, an arithmetic
computation may exceed the maximum allowed value of a number, or an attempt
                                                              ^^^^^^^^^^^^^
may be made to access an array component by using an incorrect index value.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To deal with such error situations, the statements of a program unit can be
textually followed by exception handlers that specify the actions to be taken
when the error situation arises.  Exceptions can be raised explicitly by a
raise statement.
  




In <273dedb7-8d68-42d2-8602-aa44c79f3708@b9g2000yqm.googlegroups.com>, Adam Beneschan <adam@irvine.com> writes:
>On Jun 30, 4:48=A0pm, a...@anon.org (anon) wrote:
>> Read RM 3.5 =A0( 4 )
>>
>> Is "A ( 0 .. 0 )" an example of null range. =A0By the definition in RM 3.=
>5
>> ( 4 ), the Right side range (index) must be less than the Left side, so
>> "A ( 0.. 0 )" is not a valid null range statement. So, this statement
>> should generate a compiler or runtime error, because either range is not
>> a subset of the range for Strings.
>
>OK, I think I've finally figured out why we're having this confusing
>argument.  It goes way back to this post of yours:
>
>>> For Strings:
>>>                          --  'A' is a zero length string, A'Last =3D 0, =
>and
>>>                          --  put_line  ( A ( A'First .. A'Last ) ) ;
>>>                          --  does not raise an Constraint_Error even tho=
>ugh in
>>>                          --  this case it translate to:
>>>                          --  put_line  ( A ( 0 .. 0 ) ) ;
>>>  A : String :=3D ""        ;
>
>It does not translate to A (0..0); it translates to A (1..0).  If A is
>declared as in your example above, A'First will be 1 and A'Last will
>be 0.  Try it (try declaring A like that and outputting A'First and
>A'Last).  It looks like everyone else missed this original error of
>yours, which has apparently led to some confusion.
>
>In this case, A'First..A'Last, which is 1..0, is compatible with the
>subtype because it's a null range, and null ranges are compatible with
>the subtype even when the range bounds don't actually belong to the
>subtype.  0..0 is not compatible with the subtype, but you cannot
>declare a string with that index range unless you try to do it
>explicitly:
>
>   A : String (0..0);
>
>and then you *will* get a Constraint_Error.
>
>So your later assertion that follows:
>
>>> Since you can have zero length string , the index is Natual instead of P=
>ositive,
>>> because zero is in Natural but is not define in Positive. Even though th=
>e
>>> Standard package define String index as a Positive type. (GNAT)
>
>is wrong.  The index range is Positive, but null ranges don't have to
>meet that constraint.  They don't have to be Natural, either.  This is
>legal and will not raise an exception at runtime:
>
>   B : String (-9 .. -10) :=3D "";
>
>Hope this clears everything up.
>
>                                  -- Adam
>




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

* Re: unsigned type
  2009-07-01  1:39                         ` Adam Beneschan
  2009-07-02 19:04                           ` anon
@ 2009-07-02 19:49                           ` anon
  2009-07-02 21:37                             ` Adam Beneschan
                                               ` (2 more replies)
  1 sibling, 3 replies; 152+ messages in thread
From: anon @ 2009-07-02 19:49 UTC (permalink / raw)


--  Adam. 
--    Now, can you please explain the results from this program.
--
--    It just does not make sense.  Because in the second pass though  
--    Test.Put the bounds for String is ( 1..1 ) but if the procedure 
--    uses a String ( 2 .. -2 ) which neither index is not within the 
--    valid subscript range. And this is also echoed in the third pass.
--
--    Note: The RM uses ( 1 .. 0 ) but allows ( L .. R ) if L > R, for
--           null arrays.  But I think the RM and ACATS suggest that the 
--           Left side index needs to be a valid subscript of the array.
--           Which make B ( 2 .. -2 ) illegal if the B String is bound
--           by ( 1 .. 1 ).
--
with Ada.Integer_Text_IO ;
with Ada.Text_IO ;
with Ada.Exceptions ;

procedure Test is

  use Ada.Exceptions ;
  use Ada.Integer_Text_IO ;
  use Ada.Text_IO ;

  C : String := "This is a test string" ;

  --
  -- Define a Put routine for String type.
  --
  procedure Put ( B : String ) is

    begin
      New_Line ;
      Ada.Text_IO.Put ( "    B'( " ) ;
      Put ( B'First ) ;
      Ada.Text_IO.Put ( " .. " ) ;
      Put ( B'Last ) ;
      Ada.Text_IO.Put ( " ) => " ) ;
      Ada.Text_IO.Put_Line ( ( B ( B'First .. B'Last ) ) ) ;

      Ada.Text_IO.Put ( "    B'( 2 .. -2 ) => '" ) ;
      Ada.Text_IO.Put ( ( B ( 2 .. -2 ) ) ) ;
      Ada.Text_IO.Put ( ''' ) ;
      New_Line ( 2 ) ;
    end Put ;

begin

  Ada.Text_IO.Put_line ( "Normal String Print  --  Valid" ) ;
  Ada.Text_IO.Put ( "C ( C'First .. C'Last ) => " ) ;
  begin
    Test.Put ( C ( C'First .. C'Last ) ) ;
  exception
    when E : Constraint_Error =>
      Ada.Text_IO.Put_Line ( Exception_Name ( E ) & 
                             " => " &
                             Exception_Message ( E ) ) ;
  end ;
  New_Line ;

  Ada.Text_IO.Put_line ( "Normal Sub String Print  --  Invalid???" ) ;
  Ada.Text_IO.Put ( "C ( C'First .. C'First ) => " ) ;
  begin
    Test.Put ( C ( C'First .. C'First ) ) ;
  exception
    when E : Constraint_Error =>
      Ada.Text_IO.Put_Line ( Exception_Name ( E ) & 
                             " => " &
                             Exception_Message ( E ) ) ;
  end ;
  New_Line ;


  Ada.Text_IO.Put_line ( "Normal Sub String Print  --  Invalid???" ) ;
  Ada.Text_IO.Put ( "C ( ( C'First + 4 ) .. ( C'Last - 4 ) ) => " ) ;
  begin
    Test.Put ( C ( ( C'First + 4 ) .. ( C'Last - 4 ) ) ) ;
  exception
    when E : Constraint_Error =>
      Ada.Text_IO.Put_Line ( Exception_Name ( E ) & 
                             " => " &
                             Exception_Message ( E ) ) ;
  end ;
  New_Line ;

end Test ;

In <273dedb7-8d68-42d2-8602-aa44c79f3708@b9g2000yqm.googlegroups.com>, Adam Beneschan <adam@irvine.com> writes:
>On Jun 30, 4:48=A0pm, a...@anon.org (anon) wrote:
>> Read RM 3.5 =A0( 4 )
>>
>> Is "A ( 0 .. 0 )" an example of null range. =A0By the definition in RM 3.=
>5
>> ( 4 ), the Right side range (index) must be less than the Left side, so
>> "A ( 0.. 0 )" is not a valid null range statement. So, this statement
>> should generate a compiler or runtime error, because either range is not
>> a subset of the range for Strings.
>
>OK, I think I've finally figured out why we're having this confusing
>argument.  It goes way back to this post of yours:
>
>>> For Strings:
>>>                          --  'A' is a zero length string, A'Last =3D 0, =
>and
>>>                          --  put_line  ( A ( A'First .. A'Last ) ) ;
>>>                          --  does not raise an Constraint_Error even tho=
>ugh in
>>>                          --  this case it translate to:
>>>                          --  put_line  ( A ( 0 .. 0 ) ) ;
>>>  A : String :=3D ""        ;
>
>It does not translate to A (0..0); it translates to A (1..0).  If A is
>declared as in your example above, A'First will be 1 and A'Last will
>be 0.  Try it (try declaring A like that and outputting A'First and
>A'Last).  It looks like everyone else missed this original error of
>yours, which has apparently led to some confusion.
>
>In this case, A'First..A'Last, which is 1..0, is compatible with the
>subtype because it's a null range, and null ranges are compatible with
>the subtype even when the range bounds don't actually belong to the
>subtype.  0..0 is not compatible with the subtype, but you cannot
>declare a string with that index range unless you try to do it
>explicitly:
>
>   A : String (0..0);
>
>and then you *will* get a Constraint_Error.
>
>So your later assertion that follows:
>
>>> Since you can have zero length string , the index is Natual instead of P=
>ositive,
>>> because zero is in Natural but is not define in Positive. Even though th=
>e
>>> Standard package define String index as a Positive type. (GNAT)
>
>is wrong.  The index range is Positive, but null ranges don't have to
>meet that constraint.  They don't have to be Natural, either.  This is
>legal and will not raise an exception at runtime:
>
>   B : String (-9 .. -10) :=3D "";
>
>Hope this clears everything up.
>
>                                  -- Adam
>




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

* Re: unsigned type
  2009-07-02 19:49                           ` anon
@ 2009-07-02 21:37                             ` Adam Beneschan
  2009-07-03  1:42                             ` anon
  2009-07-03  7:07                             ` Jean-Pierre Rosen
  2 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-07-02 21:37 UTC (permalink / raw)


On Jul 2, 12:49 pm, a...@anon.org (anon) wrote:
> --  Adam.
> --    Now, can you please explain the results from this program.
> --
> --    It just does not make sense.  Because in the second pass though  
> --    Test.Put the bounds for String is ( 1..1 ) but if the procedure
> --    uses a String ( 2 .. -2 ) which neither index is not within the
> --    valid subscript range. And this is also echoed in the third pass.
> --
> --    Note: The RM uses ( 1 .. 0 ) but allows ( L .. R ) if L > R, for
> --           null arrays.  But I think the RM and ACATS suggest that the
> --           Left side index needs to be a valid subscript of the array.

No, they don't.  Read 4.1.2(7).  If you believe there's a clause in
the RM that suggests that the left index needs to be in range, please
give a citation.  If there really is an ambiguity in the RM, I'll look
into it and say something about it to people who could fix it.  But
it's almost certain that you're just misinterpreting something.


> --           Which make B ( 2 .. -2 ) illegal if the B String is bound
> --           by ( 1 .. 1 ).

Nope.  It's not illegal, and it won't raise an exception.

                   -- Adam




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

* Re: unsigned type
  2009-06-29 14:18       ` Ludovic Brenta
  2009-06-29 15:40         ` Robert A Duff
@ 2009-07-03  1:41         ` Rob Solomon
  2009-07-03  7:12           ` Learning Ada (Was: unsigned type) Jacob Sparre Andersen
  1 sibling, 1 reply; 152+ messages in thread
From: Rob Solomon @ 2009-07-03  1:41 UTC (permalink / raw)


>Rob Solomon wrote on comp.lang.ada:
>> I was able to use the Natural and Positive. �
>>
>> Now I'm trying to understand Mod types.
>>
>> I tried this:
>> type card31 is mod 2_147_483_648;
>> type card32 is mod 4_294_967_296;
>> c31 : Card31;
>> c32: Card32;
>> LI : Long_Integer;
>> and
>>
>> LI := Long_Integer(c32);
>>
>> How to I output c31 and c32? �Modula-2 uses WriteCard or CardToString
>> and WriteString
>>
>> I tried using Put, but I got an error saying that correct procedure
>> could not be found, or something like that.
>>
>> Put(LI) works until the value of LI > 2**31, even for c32.
>
>Ada.Text_IO.Put_Line (Card31'Image (c31));
>
>or
>
>   package C31_IO is new Ada.Text_IO.Modular_Text_IO (Num => Card31);
>begin
>   C31_IO.Put (c31);
>
>But I have three suggestions:
>
>- rather than "type card31 is mod 2_147_483_648", write "type card31
>is mod 2**31;"
>
>- do not declare machine-oriented types like card31 or card32 in the
>first place; instead, define application-oriented types like
>"Temperature" or whatever
>
>- before you define modular types, explain to yourself why you need
>the wrap-around semantics or the bitwise operators (modular types have
>them, signed integer types don't).

I am trying to learn the language, so that is why I'm playing w/
these.  I am very familiar w/ Modula-2 and am trying to extend what I
do know to what I don't.

I bought Programming In Ada 2005 by John Barnes and Ada as a Second
Language by Norman Cohen.  

Ada as a Second Language is a far better book to learn from.  My
earlier posts were because I first opened the John Barnes book and
that left me w/ more questions than answers.  It introduces very
advanced concepts like OOP, pointers, abstract types, etc before loops
are covered.  That is, he writes about advanced data structures before
covering more basic control structures.  This made it very hard for me
to follow.  

So I am going onto the Norman Cohen book.  This is much better
organized for a newcomer.

I learned how to program by punching cards; I know how to write
programs.  Norm Cohen is much better at instruction than John Barnes.

I will keep reading before I post much more.

--rob



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

* Re: unsigned type
  2009-07-02 19:49                           ` anon
  2009-07-02 21:37                             ` Adam Beneschan
@ 2009-07-03  1:42                             ` anon
  2009-07-03  2:10                               ` Adam Beneschan
  2009-07-03  7:07                             ` Jean-Pierre Rosen
  2 siblings, 1 reply; 152+ messages in thread
From: anon @ 2009-07-03  1:42 UTC (permalink / raw)


--
-- Just a side note.   Found while using a search engine.
--
with Ada.Text_IO ;
use  Ada.Text_IO ;

procedure Temp is

    C : constant String := ( 1..0 => 'A' ) ; 
    --
    --  So, what happens to the 'A' and why does the compiler allow 
    --  the constant 'A' when it result will be a null array.
    --
    --  If you use ( 1..0 => 'A' ) you must provide an unusable single
    --  Character, double quotes or emply quote are illegal.  Logic 
    --  suggest that the statement should be
    --  C : constant String := ( 1..0 => '' ) ;
    --
    D : constant String := "" ; 

begin

  Put_line ( "C => '" & C & "'  =  '" & C ( 1..0 ) & "'" ) ;
  New_Line ;

  Put_Line ( "is C equal to D => " & Boolean'Image ( C = D ) ) ;
  New_Line ;
 
end Temp ;


In <4b83m.98382$d36.15650@bgtnsc04-news.ops.worldnet.att.net>, anon@anon.org (anon) writes:
>--  Adam. 
>--    Now, can you please explain the results from this program.
>--
>--    It just does not make sense.  Because in the second pass though  
>--    Test.Put the bounds for String is ( 1..1 ) but if the procedure 
>--    uses a String ( 2 .. -2 ) which neither index is not within the 
>--    valid subscript range. And this is also echoed in the third pass.
>--
>--    Note: The RM uses ( 1 .. 0 ) but allows ( L .. R ) if L > R, for
>--           null arrays.  But I think the RM and ACATS suggest that the 
>--           Left side index needs to be a valid subscript of the array.
>--           Which make B ( 2 .. -2 ) illegal if the B String is bound
>--           by ( 1 .. 1 ).
>--
>with Ada.Integer_Text_IO ;
>with Ada.Text_IO ;
>with Ada.Exceptions ;
>
>procedure Test is
>
>  use Ada.Exceptions ;
>  use Ada.Integer_Text_IO ;
>  use Ada.Text_IO ;
>
>  C : String := "This is a test string" ;
>
>  --
>  -- Define a Put routine for String type.
>  --
>  procedure Put ( B : String ) is
>
>    begin
>      New_Line ;
>      Ada.Text_IO.Put ( "    B'( " ) ;
>      Put ( B'First ) ;
>      Ada.Text_IO.Put ( " .. " ) ;
>      Put ( B'Last ) ;
>      Ada.Text_IO.Put ( " ) => " ) ;
>      Ada.Text_IO.Put_Line ( ( B ( B'First .. B'Last ) ) ) ;
>
>      Ada.Text_IO.Put ( "    B'( 2 .. -2 ) => '" ) ;
>      Ada.Text_IO.Put ( ( B ( 2 .. -2 ) ) ) ;
>      Ada.Text_IO.Put ( ''' ) ;
>      New_Line ( 2 ) ;
>    end Put ;
>
>begin
>
>  Ada.Text_IO.Put_line ( "Normal String Print  --  Valid" ) ;
>  Ada.Text_IO.Put ( "C ( C'First .. C'Last ) => " ) ;
>  begin
>    Test.Put ( C ( C'First .. C'Last ) ) ;
>  exception
>    when E : Constraint_Error =>
>      Ada.Text_IO.Put_Line ( Exception_Name ( E ) & 
>                             " => " &
>                             Exception_Message ( E ) ) ;
>  end ;
>  New_Line ;
>
>  Ada.Text_IO.Put_line ( "Normal Sub String Print  --  Invalid???" ) ;
>  Ada.Text_IO.Put ( "C ( C'First .. C'First ) => " ) ;
>  begin
>    Test.Put ( C ( C'First .. C'First ) ) ;
>  exception
>    when E : Constraint_Error =>
>      Ada.Text_IO.Put_Line ( Exception_Name ( E ) & 
>                             " => " &
>                             Exception_Message ( E ) ) ;
>  end ;
>  New_Line ;
>
>
>  Ada.Text_IO.Put_line ( "Normal Sub String Print  --  Invalid???" ) ;
>  Ada.Text_IO.Put ( "C ( ( C'First + 4 ) .. ( C'Last - 4 ) ) => " ) ;
>  begin
>    Test.Put ( C ( ( C'First + 4 ) .. ( C'Last - 4 ) ) ) ;
>  exception
>    when E : Constraint_Error =>
>      Ada.Text_IO.Put_Line ( Exception_Name ( E ) & 
>                             " => " &
>                             Exception_Message ( E ) ) ;
>  end ;
>  New_Line ;
>
>end Test ;
>
>In <273dedb7-8d68-42d2-8602-aa44c79f3708@b9g2000yqm.googlegroups.com>, Adam Beneschan <adam@irvine.com> writes:
>>On Jun 30, 4:48=A0pm, a...@anon.org (anon) wrote:
>>> Read RM 3.5 =A0( 4 )
>>>
>>> Is "A ( 0 .. 0 )" an example of null range. =A0By the definition in RM 3.=
>>5
>>> ( 4 ), the Right side range (index) must be less than the Left side, so
>>> "A ( 0.. 0 )" is not a valid null range statement. So, this statement
>>> should generate a compiler or runtime error, because either range is not
>>> a subset of the range for Strings.
>>
>>OK, I think I've finally figured out why we're having this confusing
>>argument.  It goes way back to this post of yours:
>>
>>>> For Strings:
>>>>                          --  'A' is a zero length string, A'Last =3D 0, =
>>and
>>>>                          --  put_line  ( A ( A'First .. A'Last ) ) ;
>>>>                          --  does not raise an Constraint_Error even tho=
>>ugh in
>>>>                          --  this case it translate to:
>>>>                          --  put_line  ( A ( 0 .. 0 ) ) ;
>>>>  A : String :=3D ""        ;
>>
>>It does not translate to A (0..0); it translates to A (1..0).  If A is
>>declared as in your example above, A'First will be 1 and A'Last will
>>be 0.  Try it (try declaring A like that and outputting A'First and
>>A'Last).  It looks like everyone else missed this original error of
>>yours, which has apparently led to some confusion.
>>
>>In this case, A'First..A'Last, which is 1..0, is compatible with the
>>subtype because it's a null range, and null ranges are compatible with
>>the subtype even when the range bounds don't actually belong to the
>>subtype.  0..0 is not compatible with the subtype, but you cannot
>>declare a string with that index range unless you try to do it
>>explicitly:
>>
>>   A : String (0..0);
>>
>>and then you *will* get a Constraint_Error.
>>
>>So your later assertion that follows:
>>
>>>> Since you can have zero length string , the index is Natual instead of P=
>>ositive,
>>>> because zero is in Natural but is not define in Positive. Even though th=
>>e
>>>> Standard package define String index as a Positive type. (GNAT)
>>
>>is wrong.  The index range is Positive, but null ranges don't have to
>>meet that constraint.  They don't have to be Natural, either.  This is
>>legal and will not raise an exception at runtime:
>>
>>   B : String (-9 .. -10) :=3D "";
>>
>>Hope this clears everything up.
>>
>>                                  -- Adam
>>
>




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

* Re: unsigned type
  2009-07-03  1:42                             ` anon
@ 2009-07-03  2:10                               ` Adam Beneschan
  0 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-07-03  2:10 UTC (permalink / raw)


On Jul 2, 6:42 pm, a...@anon.org (anon) wrote:
> --
> -- Just a side note.   Found while using a search engine.
> --
> with Ada.Text_IO ;
> use  Ada.Text_IO ;
>
> procedure Temp is
>
>     C : constant String := ( 1..0 => 'A' ) ;
>     --
>     --  So, what happens to the 'A' and why does the compiler allow
>     --  the constant 'A' when it result will be a null array.

Nothing happens to it.  This has been a known feature of Ada 83 and
Ada 95 forever; the only way to set up an empty array aggregate is to
provide a fake value.  It was particularly annoying when you had an
array of a record type; I often had to declare a useless dummy
variable of that record type just so I could say (1 .. 0 => Dummy).
There have been proposals to allow "null array" similar to the (null
record) aggregate, but they got nowhere.

Those proposals aren't needed any more anyway, since in Ada 2005 you
can say ( 1..0 => <> ) regardless of the element type.

>     --
>     --  If you use ( 1..0 => 'A' ) you must provide an unusable single
>     --  Character, double quotes or emply quote are illegal.  Logic
>     --  suggest that the statement should be
>     --  C : constant String := ( 1..0 => '' ) ;

Oh goodness.  The syntax '' doesn't mean anything in Ada, and this
would screw up every parser in the world because when they see two
single quotes together they think it's going to be a single '
character, i.e. '''.  Anyway, you can use <> so there's no longer any
need for a new syntax.

                        -- Adam




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

* Re: unsigned type
  2009-07-02 19:49                           ` anon
  2009-07-02 21:37                             ` Adam Beneschan
  2009-07-03  1:42                             ` anon
@ 2009-07-03  7:07                             ` Jean-Pierre Rosen
  2009-07-03 20:53                               ` anon
  2 siblings, 1 reply; 152+ messages in thread
From: Jean-Pierre Rosen @ 2009-07-03  7:07 UTC (permalink / raw)


anon a �crit :
> --  Adam. 
> --    Now, can you please explain the results from this program.
Please don't try to make things more complicated than they are.

The rule is simple: no bounds checking on null arrays. Full stop.
Or if you prefer, here is how the check happens:

if S'Last >= S'First then
   if S'Last not in S'Range
      or S'First not in S'Range
   then
      raise Constraint_Error;
   end if;
end if;
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



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

* Learning Ada (Was: unsigned type)
  2009-07-03  1:41         ` Rob Solomon
@ 2009-07-03  7:12           ` Jacob Sparre Andersen
  2009-07-03  8:38             ` Learning Ada Peter Hermann
  2009-07-03 22:20             ` Learning Ada (Was: unsigned type) anon
  0 siblings, 2 replies; 152+ messages in thread
From: Jacob Sparre Andersen @ 2009-07-03  7:12 UTC (permalink / raw)


Rob Solomon wrote:

> Ada as a Second Language is a far better book to learn from.  My
> earlier posts were because I first opened the John Barnes book and
> that left me w/ more questions than answers.  It introduces very
> advanced concepts like OOP, pointers, abstract types, etc before
> loops are covered.  That is, he writes about advanced data
> structures before covering more basic control structures.  This made
> it very hard for me to follow.

I would say that the way Barnes' book is structured points out a very
important aspect of Ada; Types are important!

When you write a program in Ada, you should start out by considering
which data you want to handle, and then declare the appropriate data
types for handling these data.  Once you have declared the types, you
can start writing algorithms which handle the data.

It might be to push things a bit too far, but I think it would be
beneficial, if the types Float and Integer were removed from the
language.

> So I am going onto the Norman Cohen book.  This is much better
> organized for a newcomer.

Personally I learned Ada (95) from the Language Reference Manual.

Greetings,

Jacob
-- 
"It is a syntax error to write FORTRAN while not wearing a blue tie."



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

* Re: Learning Ada
  2009-07-03  7:12           ` Learning Ada (Was: unsigned type) Jacob Sparre Andersen
@ 2009-07-03  8:38             ` Peter Hermann
  2009-07-03  9:44               ` Georg Bauhaus
  2009-07-03 22:20             ` Learning Ada (Was: unsigned type) anon
  1 sibling, 1 reply; 152+ messages in thread
From: Peter Hermann @ 2009-07-03  8:38 UTC (permalink / raw)


Jacob Sparre Andersen <sparre@nbi.dk> wrote:
> It might be to push things a bit too far, but I think it would be
> beneficial, if the types Float and Integer were removed from the
> language.

caveat.
pragmatism needs them due to a lot of reasons:
I would need a full day to list them.



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

* Re: Learning Ada
  2009-07-03  8:38             ` Learning Ada Peter Hermann
@ 2009-07-03  9:44               ` Georg Bauhaus
  0 siblings, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-03  9:44 UTC (permalink / raw)


Peter Hermann schrieb:
> Jacob Sparre Andersen <sparre@nbi.dk> wrote:
>> It might be to push things a bit too far, but I think it would be
>> beneficial, if the types Float and Integer were removed from the
>> language.
> 
> caveat.
> pragmatism needs them due to a lot of reasons:
> I would need a full day to list them.

I can't help thinking that claiming "pragmatism" to
be a quality of Standard.Integer use is what laziness
would like it to be, no offence intended:
Effects of predefined types will make people debug
and rewrite, sooner or later, as seen. Using C, you
are almost forced to use int from the C standard very
often, if only because C culture makes C programmers
frown upon better types like int wrapped in a struct
or like using enum where appropriate.
You Get Things Done (TM) very quickly this way--it's just
that Things vanish under some carpet to rot and "develop".

Imagine an Ada culture without Float and Integer.
Would Ada programmers (possibly grouped by prior
exposure to other type systems) start writing

package Everywhere is

   type Integer is range -(2**31) .. +(2**31) -1 ;
     -- be pragmatic

   type Float ...;
     -- be pragmatic

end Everywhere;

and use only these types in their programs?

Alternatives include Copy&Paset or boiler plate macros: have
your editor prompt for the range bounds of a user defined
integer type when needed, and make it insert the definition.
Done.



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

* Re: unsigned type
  2009-07-03  7:07                             ` Jean-Pierre Rosen
@ 2009-07-03 20:53                               ` anon
  2009-07-03 21:24                                 ` Georg Bauhaus
  2009-07-03 21:46                                 ` Adam Beneschan
  0 siblings, 2 replies; 152+ messages in thread
From: anon @ 2009-07-03 20:53 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

Based on the Ada LRM and the ACATS tests.

Now there is no RM rule that states you check if the Left > Right first, 
before verifying if the bounds are legal. Since the RM does not directly 
give one permission to use an illegal index value, then one should assume 
that all index must be valid before checking for a null array. Actually, 
Ada RM 0 ( 29 ) states that it is illegal and the program shall create 
an exception if the program "access an array component by using an 
incorrect index value". Also, a number of ACATS test suggest this as well 
and the program below will illustrate this. With that stated from the RM 
the program shall 

 if S'First in S'Range and then S'Last in S'Range then 
   if S'First <= S'Last then
     -- access/create an array bound by ( S'First .. S'Last )
   else
    -- return a null created array access
   end if ;
 else
  raise Constraint_Error ;
 end if ;

You have to look at the whole RM to find out if there are other sections 
that may clarify a statements or allow an exception. But there is no 
RM rules that allows an out of bounds index to be used.

Also, no where in the body of the RM does it say that ( 1 .. 0 ) is a 
valid, it is only used in a number of examples. And how many editors for 
RM 83 (pre Randy) check, double check and even triple check those examples. 
( 1 .. 0 ) may be a special case, but it should state that in a rule in the 
body of the RM, not just shown as an example, because how many books have 
examples that are wrong, even after the third version has been published.

And actually, a number of ACATS tests, show that both index bounds, that is, 
the Left and the Right side must be within the valid range of the subscript 
type, even for a null array. Now, the RM 3.5 ( 4 ) states that if the Right 
index is less the Left you have a null array, but it does not say rather the 
bounds must be within the legal range of the index type or not. But due to 
other parts of RM you should assume that all index must be valid even in 
creating a null array.

--
--  An example to prove my point.
--

procedure u is

    -- copied from ACATS "B420001.A"

    type M5 is mod 5 ;
    type String_5 is array ( M5 range <> ) of Character ;
    subtype String_5_5 is String_5 ( 4..3 ) ;
    Null_5    : constant String_5   := "" ; -- ERROR: Would raise C_E.
    OK_Null_5 :          String_5_5 := "" ; -- OK


-- ------------------------------------------------------------------------ --
--  Now these "Null array" type statement are Illegal. And will raise C_E.  --
--  GNAT compiler does flag these statement as ERROR                        --
-- ------------------------------------------------------------------------ --

    -- both indexes are "out of bounds"

    Check_Null_5_A : String_5 := ( 100 .. -100 => 'A' ) ;
    subtype String_5_A is String_5 ( 100 .. -100 ) ;

    -- Left index is valid, with right index "out of bounds"

    Check_Null_5_C : String_5 := ( 0 .. -100 => 'C' ) ;
    subtype String_5_C is String_5 ( 0 .. -100 ) ;

    -- Left index is "out of bounds", with the right index valid 

    Check_Null_5_B : String_5 := ( 100 .. 3 => 'B' ) ;
    subtype String_5_B is String_5 ( 100 .. 3 ) ;

begin
  null ;
end u ;



In <bnak2h.o3u.ln@hunter.axlog.fr>, Jean-Pierre Rosen <rosen@adalog.fr> writes:
>anon a �crit :
>> --  Adam. 
>> --    Now, can you please explain the results from this program.
>Please don't try to make things more complicated than they are.
>
>The rule is simple: no bounds checking on null arrays. Full stop.
>Or if you prefer, here is how the check happens:
>
>if S'Last >= S'First then
>   if S'Last not in S'Range
>      or S'First not in S'Range
>   then
>      raise Constraint_Error;
>   end if;
>end if;
>-- 
>---------------------------------------------------------
>           J-P. Rosen (rosen@adalog.fr)
>Visit Adalog's web site at http://www.adalog.fr




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

* Re: unsigned type
  2009-07-03 20:53                               ` anon
@ 2009-07-03 21:24                                 ` Georg Bauhaus
  2009-07-04  9:09                                   ` anon
  2009-07-03 21:46                                 ` Adam Beneschan
  1 sibling, 1 reply; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-03 21:24 UTC (permalink / raw)


anon wrote:

> Since the RM does not directly 
> give one permission to use an illegal index value, then one should assume 
> that all index must be valid before checking for a null array. 

To "assume" formal properties like index validity seems inadequate:
this is about index ranges, not index values, and about what the RM
has to say about the formal notion of a "null range" (as has now been
said many times).

> Actually, 
> Ada RM 0 ( 29 ) states that it is illegal and the program shall create 
> an exception if the program "access an array component by using an 
> incorrect index value".

There isn't any access to an array component through a null range.
For indexing an array component, one must have an index value.
There is no value in a null range.  Therefore, there is no
access to an array component.


> Also, a number of ACATS test suggest this as well 
> and the program below will illustrate this. With that stated from the RM 
> the program shall 
> 
>  if S'First in S'Range and then S'Last in S'Range then 
>    if S'First <= S'Last then
>      -- access/create an array bound by ( S'First .. S'Last )
>    else
>     -- return a null created array access
>    end if ;
>  else
>   raise Constraint_Error ;
>  end if ;
> 
> You have to look at the whole RM to find out if there are other sections 
> that may clarify a statements or allow an exception. But there is no 
> RM rules that allows an out of bounds index to be used.

Maybe the verse and illustrations given by J.-P. Rosen and
Adam Beneschan have slipped:  There are RM rules regarding
null ranges.  The construct "Greater .. Smaller" as used in, say,
initializing a null string refers to null ranges, so not to any
index value at all.




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

* Re: unsigned type
  2009-07-03 20:53                               ` anon
  2009-07-03 21:24                                 ` Georg Bauhaus
@ 2009-07-03 21:46                                 ` Adam Beneschan
  2009-07-04 12:39                                   ` Martin
  1 sibling, 1 reply; 152+ messages in thread
From: Adam Beneschan @ 2009-07-03 21:46 UTC (permalink / raw)


On Jul 3, 1:53 pm, a...@anon.org (anon) wrote:
> Based on the Ada LRM and the ACATS tests.
>
> Now there is no RM rule that states you check if the Left > Right first,
> before verifying if the bounds are legal.

Yes, there is, and we have already told you what they are.  4.1.2(7)
says that for a slice, "If the slice is not a null slice (a slice
where the discrete_range is a null range), then a check is made that
the bounds... belong...".  Since the check is not made for null
slices, then yes, you do have to check first.  3.5(8) says that a
range is compatible with a subtype if it is a null range or if the
bounds belong, so again you have to check for a null range before
making sure the bounds are in range.  But both of these RM paragraphs
have already been pointed out to you, and you apparently didn't bother
to read them but are still insisting you are right, so I don't know
what the point of my spelling this out for you is since you probably
won't pay any attention to this either.  So I think this will have to
be my last contribution on this subject.  Of course, most of the
people on this newsgroup are wondering why I didn't quit long ago.


> Since the RM does not directly
> give one permission to use an illegal index value, then one should assume
> that all index must be valid before checking for a null array. Actually,
> Ada RM 0 ( 29 ) states that it is illegal and the program shall create
> an exception if the program "access an array component by using an
> incorrect index value".

When you are creating a null array slice you are not accessing *any*
array component, since a null slice has no components.  So how would
that paragraph apply, even if it were a language rule and not just an
example in the Language Summary?


> And actually, a number of ACATS tests, show that both index bounds, that is,
> the Left and the Right side must be within the valid range of the subscript
> type, even for a null array. Now, the RM 3.5 ( 4 ) states that if the Right
> index is less the Left you have a null array, but it does not say rather the
> bounds must be within the legal range of the index type or not.

The parts of the RM which we have pointed out, and that you apparently
have not bothered to read, do say explicitly that the bounds of a null
array don't have to be in range.

> But due to
> other parts of RM you should assume that all index must be valid even in
> creating a null array.
>
> --
> --  An example to prove my point.

No, it doesn't.  This is a special case because the integer type is a
*modular* type.  Yes, the rules for modular types make things very
different.  I could go through the rules and explain exactly why this
is so, but it isn't going to matter since you won't believe me and
you'll just cite some other inapplicable general principle somewhere
else in the RM to argue your point and ignore the specific details of
what the rules actually say.  I'll just say that null strings don't
work with modular index types because the 'First of the string is the
lower bound of the subtype, which is 0, and the 'Last is what you get
by subtracting 1, which is 0-1=4 since this is a modular type, and a
string whose bounds are (0..4) can't be a null string, which is why an
error will result.  Another reason for errors in this test is because
the base range of modular types is defined differently than for signed
integer types.  Actually, you *could* cause a similar problem with a
signed integer type, but not with String because the lower bound is 1;
you'd need to define your own array type whose index range starts with
the smallest possible value in the *base range* of the integer
(something like -2**32 or -2**64), which then gets an error because
you can't subtract one from it.

                                         -- Adam


> --
>
> procedure u is
>
>     -- copied from ACATS "B420001.A"
>
>     type M5 is mod 5 ;
>     type String_5 is array ( M5 range <> ) of Character ;
>     subtype String_5_5 is String_5 ( 4..3 ) ;
>     Null_5    : constant String_5   := "" ; -- ERROR: Would raise C_E.
>     OK_Null_5 :          String_5_5 := "" ; -- OK
>
> -- ------------------------------------------------------------------------ --
> --  Now these "Null array" type statement are Illegal. And will raise C_E.  --
> --  GNAT compiler does flag these statement as ERROR                        --
> -- ------------------------------------------------------------------------ --
>
>     -- both indexes are "out of bounds"
>
>     Check_Null_5_A : String_5 := ( 100 .. -100 => 'A' ) ;
>     subtype String_5_A is String_5 ( 100 .. -100 ) ;
>
>     -- Left index is valid, with right index "out of bounds"
>
>     Check_Null_5_C : String_5 := ( 0 .. -100 => 'C' ) ;
>     subtype String_5_C is String_5 ( 0 .. -100 ) ;
>
>     -- Left index is "out of bounds", with the right index valid
>
>     Check_Null_5_B : String_5 := ( 100 .. 3 => 'B' ) ;
>     subtype String_5_B is String_5 ( 100 .. 3 ) ;
>
> begin
>   null ;
> end u ;
>
> In <bnak2h.o3u...@hunter.axlog.fr>, Jean-Pierre Rosen <ro...@adalog.fr> writes:
>
>
>
> >anon a écrit :
> >> --  Adam.
> >> --    Now, can you please explain the results from this program.
> >Please don't try to make things more complicated than they are.
>
> >The rule is simple: no bounds checking on null arrays. Full stop.
> >Or if you prefer, here is how the check happens:
>
> >if S'Last >= S'First then
> >   if S'Last not in S'Range
> >      or S'First not in S'Range
> >   then
> >      raise Constraint_Error;
> >   end if;
> >end if;
> >--
> >---------------------------------------------------------
> >           J-P. Rosen (ro...@adalog.fr)
> >Visit Adalog's web site athttp://www.adalog.fr- Hide quoted text -
>
> - Show quoted text -




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

* Re: Learning Ada (Was: unsigned type)
  2009-07-03  7:12           ` Learning Ada (Was: unsigned type) Jacob Sparre Andersen
  2009-07-03  8:38             ` Learning Ada Peter Hermann
@ 2009-07-03 22:20             ` anon
  2009-07-04 14:53               ` Georg Bauhaus
  1 sibling, 1 reply; 152+ messages in thread
From: anon @ 2009-07-03 22:20 UTC (permalink / raw)


Standards are the way to go.  
How would you like to define a Boolean alone with the universal_integer 
and universal_real types. Then have to define operations for all of those 
types for every program.  All you would have to do is rebuild the Standard 
specification package and include a body for the operations. Now, if 
someone needs to modify the program then they need the new Standard package.
But wait a minute, without the built-in standards and the compiler 
understatement of those types (Boolean, universal_integer and universal_real) 
the compiler could not understand how to build you new Standard package. The 
compiler must have a bases for those standards in order to allow you to 
redefine those standard. Even in GNAT you can rewrite the Standard package, 
but it still will fall back and use the built-in Standard operations.



Also, Its kind of funny.  Other than me not one person here tried to answer the 
original person question from "unsigned type".

I saw the title "unsigned type" and stated they are defined in predefined in the 
Interface package. But if he looked at the package he would get an example of 
what he could do to define a special type.

But no one else tried to define the type he was truly looking for. Some gave a 
sentence or two stating that CARDINAL was like a Natural or etc. But no one 
posted a statement like

  type CARDINAL is ... ;

and filled in the details, which is defined as a special type. Now, if Ludovic 
Brenta, was correct that most Ada programmers prefer to create their own 
types, then where were those programmers posting that type of statement 
for an answer. 



In <878wj61bpo.fsf_-_@nbi.dk>, Jacob Sparre Andersen <sparre@nbi.dk> writes:
>Rob Solomon wrote:
>
>> Ada as a Second Language is a far better book to learn from.  My
>> earlier posts were because I first opened the John Barnes book and
>> that left me w/ more questions than answers.  It introduces very
>> advanced concepts like OOP, pointers, abstract types, etc before
>> loops are covered.  That is, he writes about advanced data
>> structures before covering more basic control structures.  This made
>> it very hard for me to follow.
>
>I would say that the way Barnes' book is structured points out a very
>important aspect of Ada; Types are important!
>
>When you write a program in Ada, you should start out by considering
>which data you want to handle, and then declare the appropriate data
>types for handling these data.  Once you have declared the types, you
>can start writing algorithms which handle the data.
>
>It might be to push things a bit too far, but I think it would be
>beneficial, if the types Float and Integer were removed from the
>language.
>
>> So I am going onto the Norman Cohen book.  This is much better
>> organized for a newcomer.
>
>Personally I learned Ada (95) from the Language Reference Manual.
>
>Greetings,
>
>Jacob
>-- 
>"It is a syntax error to write FORTRAN while not wearing a blue tie."




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

* Re: unsigned type
  2009-07-03 21:24                                 ` Georg Bauhaus
@ 2009-07-04  9:09                                   ` anon
  2009-07-04 13:43                                     ` Georg Bauhaus
  2009-07-06  9:04                                     ` AdaMagica
  0 siblings, 2 replies; 152+ messages in thread
From: anon @ 2009-07-04  9:09 UTC (permalink / raw)


        A String literal is define in RM 4.2 ( 4, 11 ) with the String 
type defined in RM 3.6.3 ( 4 ) and its index type (Positive) is define 
in RM 3.6.3 ( 3 ) and RM 3.5.4 ( 13 ).  With the Positive base range 
being Natural defined by RM 3.5.4 ( 13..14 ).

So to create a "null range" Strings aka a null String literal, the type and 
range must be check! In the following hierarchical outline, based on RM 3.2:

  1. RM 4.2 ( 11 )  : Check if Lower bound > Base_Range'First.
                      (Lower bound must be a member of the "subtype" 
                       or Base_Range type in order to preform the 
                       comparison, so Lower Bound type is checked)

  2. RM 3.6.1 ( 4 ) : Check if both indexes values are within subtype 
                      or range type. 
                      (Upper bound is now verified to be a valid 
                       type of the range)

  3. RM 3.5         : Check if Lower bounds > Upper bounds
                      (verify the "null range" definition)

  4. Else it is not a valid null range String and a Constraint_Error 
          will be raised. 


So, is "A : String ( 1..0 )" legal.  

Yes maybe! Yes, because RM 4.2 ( 11 ) states that "for the evaluation of 
a null string literal, a check is made that its lower bound is greater 
than the lower bound of the base range of the index type.  And the Lower 
bound ( 1 ) > ( 0 ) aka Natural'First which fills the definition in 
RM 4.2 ( 11 ). And the Lower bound ( 1 ) > Upper bound ( 0 ) RM 3.5 ( 4 ). 

But there is a problem from RM 3.6.1 ( 4 ) it states that both indexes must 
be a member of the subtype for the arrays range. Since, Strings are just a 
predefined one-dimensional character array using Positives as indexes. That 
means for a String that both indexes must be a member of the Positive type 
making the ( 1..0 ) invalid, since 0 is not define as a Positive type. So, 
from RM 3.6.1 ( 4 ) this null range String is not valid.


Now, is "B : String := ( -5 .. -7 => ' ' ) ;" legal? 

First, it violates RM 4.2 ( 11 ), that is, the lower bound ( -5 ) is not 
greater than the lower bound of the base range of the index type 
Natural aka Natural'First or 0. So, from RM 4.2 ( 11 ) this should raise 
a Constraint_Error. But it does not!

And then both indexes are not valid members of either the index type 
Positive or even its base range type aka Natural. So, from RM 3.6.1 ( 4 ) 
this is an error.

But, it does comply with the "null range" in  RM 3.5 ( 4 ), where the 
lower bounds must be greater than upper bounds, but that does not 
replace the other two requirements, for a null String literal.

So, this should raise a Constraint_Error. 



In <4a4e7705$0$31863$9b4e6d93@newsspool3.arcor-online.net>, Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> writes:
>anon wrote:
>
>> Since the RM does not directly 
>> give one permission to use an illegal index value, then one should assume 
>> that all index must be valid before checking for a null array. 
>
>To "assume" formal properties like index validity seems inadequate:
>this is about index ranges, not index values, and about what the RM
>has to say about the formal notion of a "null range" (as has now been
>said many times).
>
>> Actually, 
>> Ada RM 0 ( 29 ) states that it is illegal and the program shall create 
>> an exception if the program "access an array component by using an 
>> incorrect index value".
>
>There isn't any access to an array component through a null range.
>For indexing an array component, one must have an index value.
>There is no value in a null range.  Therefore, there is no
>access to an array component.
>
>
>> Also, a number of ACATS test suggest this as well 
>> and the program below will illustrate this. With that stated from the RM 
>> the program shall 
>> 
>>  if S'First in S'Range and then S'Last in S'Range then 
>>    if S'First <= S'Last then
>>      -- access/create an array bound by ( S'First .. S'Last )
>>    else
>>     -- return a null created array access
>>    end if ;
>>  else
>>   raise Constraint_Error ;
>>  end if ;
>> 
>> You have to look at the whole RM to find out if there are other sections 
>> that may clarify a statements or allow an exception. But there is no 
>> RM rules that allows an out of bounds index to be used.
>
>Maybe the verse and illustrations given by J.-P. Rosen and
>Adam Beneschan have slipped:  There are RM rules regarding
>null ranges.  The construct "Greater .. Smaller" as used in, say,
>initializing a null string refers to null ranges, so not to any
>index value at all.
>




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

* Re: unsigned type
  2009-07-03 21:46                                 ` Adam Beneschan
@ 2009-07-04 12:39                                   ` Martin
  0 siblings, 0 replies; 152+ messages in thread
From: Martin @ 2009-07-04 12:39 UTC (permalink / raw)


Adam,

You forgot to start your explanation with a condescending 'now'! ;-)

Cheers
-- Martin



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

* Re: unsigned type
  2009-07-04  9:09                                   ` anon
@ 2009-07-04 13:43                                     ` Georg Bauhaus
  2009-07-06  9:04                                     ` AdaMagica
  1 sibling, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-04 13:43 UTC (permalink / raw)


anon wrote:
>  With the Positive base range
> being Natural defined by RM 3.5.4 ( 13..14 ).

This paragraph does not say that Positive base
is Natural at all, I think; even the definition
of Positive is not saying this, though it does
rule out Natural as a candidate:

subtype Positive is Integer range 1 .. Integer'Last;

But even so, regarding odd looking ranges like a
-5 .. -7 range constraint on what seems to be a
set of Positive String index values, consider this
program and its translation.

pragma List(On);
procedure Br is
	A: Positive range -5 .. -7; -- o.K.
	B : String := ( -5 .. -7 => ' ' ); -- o.K.

	type T is range 10 .. 20;
	C: T range -5 .. -7;  -- ``Huh?'' you might say
begin
	A := -5;
	B(B'First) := B(B'Last);
	C := -5;
	C := 15;
end Br;

First, ObjectAda, then GNAT:

Source file: ..\..\..\..\..\news\br.adb   Sat Jul 04 13:31:30 2009

    1 pragma List(On);
    2 procedure br is
    3         a: Positive range -5 .. -7;  -- o.K.
    4         b: string := String'(-5 .. -7 => ' ');  -- o.K:
    5
    6         type T is range 10 .. 20;
    7         C: T range -5 .. -7;
    8 begin
    9         a := -5;
                    *
*****Warning: LRM:11.5(17) Value outside range, Constraint_Error will be
raised
   10         B(B'First) := B(B'Last);
                  *
*****Warning: LRM:11.5(17) Value outside range, Constraint_Error will be
raised
                                *
*****Warning: LRM:11.5(17) Value outside range, Constraint_Error will be
raised
   11         C := -5;
                    *
*****Warning: LRM:11.5(17) Value outside range, Constraint_Error will be
raised
   12         c := 15;
                   *
*****Warning: LRM:11.5(17) Value outside range, Constraint_Error will be
raised
   13 end br;




GNAT GPL 2007 (20070405-41)
Copyright 1992-2007, Free Software Foundation, Inc.

Compiling: br.adb (source file time stamp: 2009-07-04 12:48:48)

     1. pragma List(On);
     2. procedure Br is
     3. 	A: Positive range -5 .. -7; -- o.K.
     4. 	B : String := ( -5 .. -7 => ' ' ); -- o.K.
     5.
     6. 	type T is range 10 .. 20;
     7. 	C: T range -5 .. -7;
     8. begin
     9. 	A := -5;
        	     |
        >>> warning: value not in range of subtype of "Standard.Integer"
defined at line 3
        >>> warning: "Constraint_Error" will be raised at run time

    10. 	B(B'First) := B(B'Last);
        	   1             3
        >>> warning: value not in range of subtype of "Standard.Integer"
defined at line 4
        >>> warning: "Constraint_Error" will be raised at run time
        >>> warning: value not in range of subtype of "Standard.Integer"
defined at line 4
        >>> warning: "Constraint_Error" will be raised at run time

    11. 	C := -5;
        	     |
        >>> warning: value not in range of subtype of "T" defined at line 7
        >>> warning: "Constraint_Error" will be raised at run time

    12. 	C := 15;
        	     |
        >>> warning: value not in range of subtype of "T" defined at line 7
        >>> warning: "Constraint_Error" will be raised at run time

    13. end Br;

 13 lines: No errors, 10 warnings


So of course there will be constraint_errors, but only
when the language requires them (that's type versus
base range versus subtype vs range subtype, and then
actually using objects etc.)

Positive range -5 .. -7 is confusing, for sure.
The fact that Some_String'First can return -5 has been confusing
before. There is no denying IMHO that this is a paradoxical
part of Ada to be clear only after you know the rules of
the RM about numbers and (sub)types...  and study explanations
given by language layers and compiler makers.

> So to create a "null range" Strings aka a null String literal, the type and 
> range must be check!

(I appreciate your stamina when resisting language
lawyerly arguments by language lawers and compiler
writers.) (Do you mean "null string literal" as in
RM 2.6(6)?)

Looking at Adam's answer:  he points out to you an
"Only If" and "Then" construction in the RM that makes
clear the order and conditionality of checks in the
case of null things. E.g. "... either a null range or ..."
where your claim about checks refers to what follows after
the "or" in the RM but you insist it is before the "or"
for null things.  The "or" invalidates your claim.


> ( 0 ) aka Natural'First

No, I don't think literal 0 is also known as Natural'First;
however, Natural'First has the value 0.  This would seem
to be a case of logical implication vs. logical equivalence?



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

* Re: Learning Ada (Was: unsigned type)
  2009-07-03 22:20             ` Learning Ada (Was: unsigned type) anon
@ 2009-07-04 14:53               ` Georg Bauhaus
  2009-07-05 23:21                 ` anon
  0 siblings, 1 reply; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-04 14:53 UTC (permalink / raw)


anon wrote:
> Standards are the way to go.  

Yes, standards are the way to go.

And this *is* standard Ada:

   type T is range 1_000_000 .. 9_999_999;

The type T has the exact same set of operations as Standard.Integer.
It is just as efficient as implementation defined Standard.Integer.
The types Integer or Boolean you mentioned are not needed in
order to define T.  Universal_integer is the type of integer
literals like 1_000_000; it is *not*  declared in package Standard, it
does not even have a name, it is just a predefined anonymous
type.

> Also, Its kind of funny.  Other than me not one person here tried to answer the 
> original person question from "unsigned type".

The first answer by Florian Weimer answered the original
question, implying, I guess, that CARDINAL is not a mod
type and so cannot be replaced with a mod type like Unsigned_N
as you seem to suggest: For Modula-2's CARDINAL, there
is overflow check control... So CARDINAL is not the same
as a modular type in Ada.

The second answer, by Albrecht K�fer, in addition
points to modular types and to how they
differ from Modula-2's CARDINAL.

Maybe it is part of Ada culture to explain how
a problem is solved in Ada, not how you can
write Ada in the language you know, even when
that might make some Ada teachers more popular
among those students who do not have the, uhm, time
to really learn Ada.



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

* Re: Learning Ada (Was: unsigned type)
  2009-07-04 14:53               ` Georg Bauhaus
@ 2009-07-05 23:21                 ` anon
  2009-07-06  0:05                   ` Ludovic Brenta
                                     ` (3 more replies)
  0 siblings, 4 replies; 152+ messages in thread
From: anon @ 2009-07-05 23:21 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5868 bytes --]

Wrong!
        I was not talking about the Ada Statements "Type" or "Subtype" but 
true Standards that go beyond Ada.

An example that is listed in the Ada RM, is the standard character sets:
  ISO 10646 Universal Multiple-Octet Coded Character Set
  ISO 8859-1 (Latin-1)

        But Ada also, use standards for it types, "Integer", and "Float', with 
their associate subtypes.  One reason but not the only reason for the range of 
these built-in types are the hardware.  If the hardware uses 32-bits integers 
then the Ada "Integer" is based on 32-bit. And in todays systems the Ada 
"Float" is normally based on the FPU (hardware) range.  And the numeric 
ranges for the FPU is based on standard that are defined and adopted by the 
agencies like IEEE and ISO. 

        But some people like "Ludovic Brenta, state that most Ada programmers 
would prefer to create their own types. In some case, that goes against the RM 
because it can create a non-standardize form of an Ada programs, that violate 
other RM rules. Plus, the RM states that a number of numeric types are 
predefined, such as "Integer", and it subtypes "Natural" and "Positive" as 
well the type "Float" and its subtypes. Redefining those predefines types are 
legal in Ada, by simply re-defining the type. Like for example, using 24 bit 
integer:

    type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ;

To use this new definition of "Integer", globally it needs to be define in the 
standard package, but for a single package or routine it better to create a new 
type or subtype and for the routine or package. But in most programming this 
is not necessary. That is, since Ada creation and the DOD dropping it full 
support of Ada, the usage for redefining the numeric data types is almost nil, 
not the norm any more.  Plus, the DOD require full documentation on all new 
define types. And no matter what type is defined the compiler will fall back to the 
basic standards of the universal-integer and universal-real aka CPU integer 
and FPU float and their operations. If you study most of the implementations of 
Ada, one can see that the types "Integer" and "Float" that are defined in the 
"Standard" package are basically equivalent to the Ada's universal-integer and 
universal-real.

        Now, "Rob Solomon" stated that he think "it would be beneficial, if 
the types Float and Integer were removed from the language". 

        First, if this could happen the RM would need a MAJOR overhaul. 
It would be easier to create a new language. Because both types are used 
throughout the RM defined packages. 

        Second, the predefined types allow for the program to be more portable, 
because a users type might not be accepted on the new system. But using the 
standards or creating a subtype from the standards is better. An example is:

    type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ;

which is a valid Ada statement but in a 32-bit and most 64-bit system this 
type is not allowed. You would need to use a special array or record type that 
is based on the universal-integer or CPU and define the operations in a math 
package or packages. There are a few special scientific projects that could 
use that type of maybe even a larger type like 1024-bit, but there's not 
enough applications for most to spend their time in creating such a package.  
Normally, its the scientist that ask for help that developes such packages for 
his project and only for his project and then sets the big price tag for others 
that package.

        Then third, is without standards types like "Integer" and "Float" how 
would the system work.  Using Ada, define a "=" or "*" without using the 
universal-integer and universal-real types or there operations.  You can not! 
You must have some basic standard types and operations to define other 
operations. Ada calls these types universal-integer and universal-real and uses 
their operations to build the predefine types and their operations.

        Fourth, is to interface with other languages. which also use standards. 
Some Ada programmer prefer pure Ada code.  Like using the "Interface" 
package to only define the standard unsigned types and to use the low-level 
shift and rotate routines for those unsigned types. But there are times when 
interfacing is required.


In <4a4f6cce$0$31869$9b4e6d93@newsspool3.arcor-online.net>, Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> writes:
>anon wrote:
>> Standards are the way to go.  
>
>Yes, standards are the way to go.
>
>And this *is* standard Ada:
>
>   type T is range 1_000_000 .. 9_999_999;
>
>The type T has the exact same set of operations as Standard.Integer.
>It is just as efficient as implementation defined Standard.Integer.
>The types Integer or Boolean you mentioned are not needed in
>order to define T.  Universal_integer is the type of integer
>literals like 1_000_000; it is *not*  declared in package Standard, it
>does not even have a name, it is just a predefined anonymous
>type.
>
>> Also, Its kind of funny.  Other than me not one person here tried to answer the 
>> original person question from "unsigned type".
>
>The first answer by Florian Weimer answered the original
>question, implying, I guess, that CARDINAL is not a mod
>type and so cannot be replaced with a mod type like Unsigned_N
>as you seem to suggest: For Modula-2's CARDINAL, there
>is overflow check control... So CARDINAL is not the same
>as a modular type in Ada.
>
>The second answer, by Albrecht K�fer, in addition
>points to modular types and to how they
>differ from Modula-2's CARDINAL.
>
>Maybe it is part of Ada culture to explain how
>a problem is solved in Ada, not how you can
>write Ada in the language you know, even when
>that might make some Ada teachers more popular
>among those students who do not have the, uhm, time
>to really learn Ada.




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

* Re: Learning Ada (Was: unsigned type)
  2009-07-05 23:21                 ` anon
@ 2009-07-06  0:05                   ` Ludovic Brenta
  2009-07-06  0:19                   ` Learning Ada Albrecht Käfer
                                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 152+ messages in thread
From: Ludovic Brenta @ 2009-07-06  0:05 UTC (permalink / raw)


anon top-posted on comp.lang.ada:
> Wrong!
>         I was not talking about the Ada Statements "Type" or "Subtype" but
> true Standards that go beyond Ada.

Please define a "true standard" (as opposed to a "standard") and what
it means for a "true standard" to "go beyond" Ada.  "go beyond" is a
non-standard phrase, it does not appear anywhere in the ARM.

[use the language-defined Integer and Float]
>         But some people like "Ludovic Brenta, state that most Ada programmers
> would prefer to create their own types.

I did not state that; I don't know what "most Ada programmers" do or
where they are, and I don't use the "lemming argument" because I
honestly don't care what "most people" do in general.  If I wanted to
do what "most people" do, I would not program in Ada.  What I said is
that it is generally *better* to use application-defined types than
language-defined types; this is the proper and intended way to use
Ada.

> In some case, that goes against the RM
> because it can create a non-standardize form of an Ada programs, that violate
> other RM rules.

If a program violates other RM rules and the compiler properly
enforces the rules, then the program won't compile.  What was your
point?

> Plus, the RM states that a number of numeric types are
> predefined, such as "Integer", and it subtypes "Natural" and "Positive" as
> well the type "Float" and its subtypes. Redefining those predefines types are
> legal in Ada, by simply re-defining the type. Like for example, using 24 bit
> integer:
>
>     type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ;

Wrong; your declaration is legal but it does not "redefine"
Standard.Integer; it defines a new type with the same name.

> To use this new definition of "Integer", globally it needs to be define in the
> standard package, but for a single package or routine it better to create a new
> type or subtype and for the routine or package.

No; it is better to define an application-specific type instead.  By
declaring a type Integer in your own package, you create a new problem
(global visibility of your new type) without solving any existing
problem, so this is not only useless but harmful.  I've seen it done
in several places before and the reasons given to me for doing that
were always wrong. At least they avoided using the name Integer but
used Integer_Type or something similarly stupid instead.  By the same
token, changing the definition of Standard.Integer achieves nothing
useful and is a lot of trouble, so don't do that.

> But in most programming this
> is not necessary. That is, since Ada creation and the DOD dropping it full
> support of Ada, the usage for redefining the numeric data types is almost nil,
> not the norm any more.  Plus, the DOD require full documentation on all new
> define types. And no matter what type is defined the compiler will fall back to the
> basic standards of the universal-integer and universal-real aka CPU integer
> and FPU float and their operations. If you study most of the implementations of
> Ada, one can see that the types "Integer" and "Float" that are defined in the
> "Standard" package are basically equivalent to the Ada's universal-integer and
> universal-real.

So what?  If you don't want compile-time type checks and only care
about the hardware-defined types, then go program in assembly
language.

>         Now, "Rob Solomon" stated that he think "it would be beneficial, if
> the types Float and Integer were removed from the language".

No, that was Jacob Sparre Andersen.

>         First, if this could happen the RM would need a MAJOR overhaul.
> It would be easier to create a new language. Because both types are used
> throughout the RM defined packages.
>
>         Second, the predefined types allow for the program to be more portable,
> because a users type might not be accepted on the new system.

I'm sure Jacob is well aware of that.  For your second objection, it
is a *Good* *Thing* if the compiler says up-front, at compile time,
whether it supports the application-defined types or not.  It is a
*Bad* *Thing* if the compiler is silent and the application later
misbehaves because the hardware doesn't support the application
constraints.

[...]
>         Then third, is without standards types like "Integer" and "Float" how
> would the system work.  Using Ada, define a "=" or "*" without using the
> universal-integer and universal-real types or there operations.  You can not!

You seem to be confusing the unioversal_integer and universal_real
types (which are anonymous) with Standard.Integer and Standard.Float,
respectively.  They are *not* the same things.  Even if
Standard.Integer and Standard.Float disappeared, unioversal_integer
and universal_real would still exist and allow the arithmetic
operations you describe.

[...]
>         Fourth, is to interface with other languages. which also use standards.
> Some Ada programmer prefer pure Ada code.  Like using the "Interface"
> package to only define the standard unsigned types and to use the low-level
> shift and rotate routines for those unsigned types. But there are times when
> interfacing is required.

For interfacing to C, you use Interfaces.C.int, not Standard.Integer,
and Interfaces.C.C_float, not Standard.Float.  For COBOL you use
Interfaces.COBOL.Binary and Interfaces.COBOL.Floating.  For Fortran,
you use Interfaces.Fortran.Fortran_Integer and
Interfaces.Fortran.Real.  If "some Ada programmers" prefer
Standard.Integer and Standard.Float against the ARM, then they are
wrong.  Nowhere does the ARM state what Standard.Integer or
Standard.Float correspond to in C, COBOL or Fortran.

--
Ludovic Brenta.



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

* Re: Learning Ada
  2009-07-05 23:21                 ` anon
  2009-07-06  0:05                   ` Ludovic Brenta
@ 2009-07-06  0:19                   ` Albrecht Käfer
  2009-07-06  2:50                     ` anon
  2009-07-06 10:53                   ` Learning Ada (Was: unsigned type) Georg Bauhaus
  2009-07-06 23:15                   ` Randy Brukardt
  3 siblings, 1 reply; 152+ messages in thread
From: Albrecht Käfer @ 2009-07-06  0:19 UTC (permalink / raw)


anon schrieb:
>         But some people like "Ludovic Brenta, state that most Ada programmers
> would prefer to create their own types. In some case, that goes against the RM
> because it can create a non-standardize form of an Ada programs, that violate
> other RM rules.

It would be really smashing if you could provide some sort of proof for
this bold claim.

> Plus, the RM states that a number of numeric types are
> predefined, such as "Integer", and it subtypes "Natural" and "Positive" as
> well the type "Float" and its subtypes.
> Redefining those predefines types are
> legal in Ada, by simply re-defining the type.

... no? Standard.Integer et al cannot be redefined. You can change the
underlying compiler, but then you could also change "begin" to "start".

> Like for example, using 24 bit integer:
>
>     type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ;
>
> To use this new definition of "Integer", globally it needs to be define in the
> standard package,

Now how would you go around doing that?

> but for a single package or routine it better to create a new
> type or subtype and for the routine or package. But in most programming this
> is not necessary. That is, since Ada creation and the DOD dropping it full
> support of Ada, the usage for redefining the numeric data types is almost nil,
> not the norm any more.  Plus, the DOD require full documentation on all new
> define types.

Why should we care about what the DoD requires again?

>         Now, "Rob Solomon" stated that he think "it would be beneficial, if
> the types Float and Integer were removed from the language".

That is a personal opinion, not a law of nature.

>         Second, the predefined types allow for the program to be more portable,
> because a users type might not be accepted on the new system. But using the
> standards or creating a subtype from the standards is better. An example is:
>
>     type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ;
>
> which is a valid Ada statement but in a 32-bit and most 64-bit system this
> type is not allowed.

There's nothing stopping you from creating a special Ada compiler
supporting arbitrary-length integers.


Albrecht



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

* Re: Learning Ada
  2009-07-06  0:19                   ` Learning Ada Albrecht Käfer
@ 2009-07-06  2:50                     ` anon
  2009-07-06  6:18                       ` AdaMagica
  0 siblings, 1 reply; 152+ messages in thread
From: anon @ 2009-07-06  2:50 UTC (permalink / raw)


Wrong!
--
--  Just to show how easy it is redefining an Integer. Or the 
--  Standard package.  Compiled with GNAT < 2010 
--
with Ada.Text_IO ;
with Standard ; -- require for redefining Standard package

procedure Temp is

  use Ada.Text_IO ;

begin

  declare 

    package Integer_IO is new
                          Ada.Text_IO.Integer_IO ( Integer ) ;
    use Integer_IO ;

  begin
      New_Line ;
      Put_line ( "Integer predefined limits" ) ;
      Put ( "Range => ( " ) ;
      Put ( Integer'First ) ;
      Put ( " .. " ) ;
      Put ( Integer'Last ) ;
      Put_Line ( " ) " ) ;
      New_Line ;
  end ;

  --
  -- Now redefine the type Integer.
  --
  declare 
 
    type Integer is range -2 ** 8 ..  2 ** 8 - 1  ;

    package Integer_IO is new Ada.Text_IO.Integer_IO ( Integer ) ;
    use Integer_IO ;

  begin
      New_Line ;
      Put_line ( "Integer redefined limits" ) ;
      Put ( "Range => ( " ) ;
      Put ( Integer'First ) ;
      Put ( " .. " ) ;
      Put ( Integer'Last ) ;
      Put_Line ( " ) " ) ;
      New_Line ;
  end ;

  --
  -- Using a new Standard package
  --

  declare 

    package Integer_IO is new
                          Ada.Text_IO.Integer_IO ( Standard.Integer ) ;
    use Integer_IO ;

  begin
      New_Line ;
      Put_line ( "Integer limits from a new Standard package" ) ;
      Put ( "Range => ( " ) ;
      Put ( Standard.Integer'First ) ;
      Put ( " .. " ) ;
      Put ( Standard.Integer'Last ) ;
      Put_Line ( " ) " ) ;
      New_Line ;
  end ;
end Temp ;


--
--  This will compile under current GNAT < 2010.  Package cut down 
--  because the complete version is too long and is not needed to 
--  make the point. But all other types and operations will fall back to 
--  GNAT built-in Standard package aka for GNAT its universal Standard
--  package.
--
package STANDARD is 

  -- The universal type universal_integer is predefined.  

  type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;

end STANDARD ; 


In <h2rgg8$blq$1@online.de>, Albrecht =?ISO-8859-1?Q?K=E4fer?= <albrecht_kaefer@yahoo.de> writes:
>anon schrieb:
>>         But some people like "Ludovic Brenta, state that most Ada programmers
>> would prefer to create their own types. In some case, that goes against the RM
>> because it can create a non-standardize form of an Ada programs, that violate
>> other RM rules.
>
>It would be really smashing if you could provide some sort of proof for
>this bold claim.
>
>> Plus, the RM states that a number of numeric types are
>> predefined, such as "Integer", and it subtypes "Natural" and "Positive" as
>> well the type "Float" and its subtypes.
>> Redefining those predefines types are
>> legal in Ada, by simply re-defining the type.
>
>.... no? Standard.Integer et al cannot be redefined. You can change the
>underlying compiler, but then you could also change "begin" to "start".
>
>> Like for example, using 24 bit integer:
>>
>>     type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ;
>>
>> To use this new definition of "Integer", globally it needs to be define in the
>> standard package,
>
>Now how would you go around doing that?
>
>> but for a single package or routine it better to create a new
>> type or subtype and for the routine or package. But in most programming this
>> is not necessary. That is, since Ada creation and the DOD dropping it full
>> support of Ada, the usage for redefining the numeric data types is almost nil,
>> not the norm any more.  Plus, the DOD require full documentation on all new
>> define types.
>
>Why should we care about what the DoD requires again?
>
>>         Now, "Rob Solomon" stated that he think "it would be beneficial, if
>> the types Float and Integer were removed from the language".
>
>That is a personal opinion, not a law of nature.
>
>>         Second, the predefined types allow for the program to be more portable,
>> because a users type might not be accepted on the new system. But using the
>> standards or creating a subtype from the standards is better. An example is:
>>
>>     type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ;
>>
>> which is a valid Ada statement but in a 32-bit and most 64-bit system this
>> type is not allowed.
>
>There's nothing stopping you from creating a special Ada compiler
>supporting arbitrary-length integers.
>
>
>Albrecht




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

* Re: Learning Ada
  2009-07-06  2:50                     ` anon
@ 2009-07-06  6:18                       ` AdaMagica
  2009-07-06  7:47                         ` Jean-Pierre Rosen
  2009-07-06 20:21                         ` anon
  0 siblings, 2 replies; 152+ messages in thread
From: AdaMagica @ 2009-07-06  6:18 UTC (permalink / raw)


Oh my dear anon, you are so wrong again.

> package STANDARD is
>
>   -- The universal type universal_integer is predefined.  
>
>   type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
>
> end STANDARD;

You do *not* redefine Standard with this declaration, you simply hide
it.

with Standard;

procedure Temp is  -- Here you will get into troubled water.

  X: Integer;  -- this is still the integer from the predefined
package Standard
  Y: STANDARD.Integer;  -- this is your INTEGER

  use Standard;

  Z: Integer := 2;  -- oh lord, what's this now?

  -- I'm not sure and I'm reluctant to do the RM exegesis to find out.
I *guess* it's your INTEGER;

  I: Integer := Z**3;  -- subtype of 3 is still the Integer defined in
                       -- the predefined Standard you've hidden
  J: Integer := Z**Z;  -- This should then be illegal because the
subtype of the right operand of **
                       -- must be the one from the hidden Standard.

end Temp;

Point is: You cannot redefine Standard! Full stop.

I invite you to find the relevant paragraphs in the RM which state
what will happen when you define a package named Standard.

And please be careful to not mix up a subtype and the type of the
subtype and the type of numeric literals. They are all different.



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

* Re: Learning Ada
  2009-07-06  6:18                       ` AdaMagica
@ 2009-07-06  7:47                         ` Jean-Pierre Rosen
  2009-07-06 20:21                         ` anon
  1 sibling, 0 replies; 152+ messages in thread
From: Jean-Pierre Rosen @ 2009-07-06  7:47 UTC (permalink / raw)


AdaMagica a �crit :
> Oh my dear anon, you are so wrong again.
> 
>> package STANDARD is
>>
>>   -- The universal type universal_integer is predefined.  
>>
>>   type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
>>
>> end STANDARD;
> 
> You do *not* redefine Standard with this declaration, you simply hide
> it.
> 
> with Standard;
> 
> procedure Temp is  -- Here you will get into troubled water.
> 
>   X: Integer;  -- this is still the integer from the predefined
> package Standard
>   Y: STANDARD.Integer;  -- this is your INTEGER
> 
>   use Standard;
> 
>   Z: Integer := 2;  -- oh lord, what's this now?
> 
>   -- I'm not sure and I'm reluctant to do the RM exegesis to find out.
> I *guess* it's your INTEGER;
No, it's the one from the real Standard.

The rule is simple: "use" is weak. It comes into play only if nothing
gets in the way (like a similar name that is directly visible, or
declared in another used package).

The regular Standard is always /directly/ visible, therefore a use
clause never brings something in front of something from the regular
Standard.
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



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

* Re: unsigned type
  2009-07-04  9:09                                   ` anon
  2009-07-04 13:43                                     ` Georg Bauhaus
@ 2009-07-06  9:04                                     ` AdaMagica
  1 sibling, 0 replies; 152+ messages in thread
From: AdaMagica @ 2009-07-06  9:04 UTC (permalink / raw)


On Jul 4, 11:09 am, a...@anon.org (anon) wrote:
>         A String literal is define in RM 4.2 ( 4, 11 ) with the String
> type defined in RM 3.6.3 ( 4 ) and its index type (Positive) is define
> in RM 3.6.3 ( 3 ) and RM 3.5.4 ( 13 ).  With the Positive base range
> being Natural defined by RM 3.5.4 ( 13..14 ).

and a lot more wrong statements.

Positive'Base is not Natural. You mix up 'subtype', 'type of a
subtype', 'base type'. They are all different.

Please see:
http://en.wikibooks.org/w/index.php?title=Ada_Programming/Type_System&stable=0&shownotice=1#Elaborated_Discussion_of_Types_for_Signed_Integer_Types

In short: The 'type' of an integer type comprises the complete set of
mathematical integers (yes, indeed).
The base type of a subtype is some compiler chosen hardware type that
comprises all values of the first subtype.

type Some_T is range 0 .. 10;

You may believe it or not, 10**10_000 is a value of the type of
Some_T; Some_T is not a type, it's the first subtype of the type of
Some_T. It's of course not in Some_T'Base for any of today's machines
(and won't be for a long time to come).

The type of T is denoted in the RM with italized font.

X: constant := Some_T'Last + 10**10_000;  -- type of X is
Universal_Integer, calculated as follows:

The result will be mathematically exact (no overflow check except for
a limitation by computer store) with the "+" operator of (the type of)
Some_T.
The literals 10 and 10_000 are of type Universal_Integer. 10 will be
implicitly converted to (the type of) Some_T or some such, 10_000 to
(the type of) Standard.Integer, then "**" will be applied to the
result returning a value of the type of Some_T. At the end, the result
is implicitly converted back to Unversal_Integer.

Universal_Integer has no operators!

So with this in mind, please rethink your arguments about String (1 ..
0), String (-5 .. -7) etc...

(This is my personal exegesis of the RM. Hope it's correct.)



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

* Re: Learning Ada (Was: unsigned type)
  2009-07-05 23:21                 ` anon
  2009-07-06  0:05                   ` Ludovic Brenta
  2009-07-06  0:19                   ` Learning Ada Albrecht Käfer
@ 2009-07-06 10:53                   ` Georg Bauhaus
  2009-07-06 19:34                     ` anon
  2009-07-06 23:15                   ` Randy Brukardt
  3 siblings, 1 reply; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-06 10:53 UTC (permalink / raw)


anon schrieb:
> Wrong!
>         I was not talking about the Ada Statements "Type" or "Subtype" but 
> true Standards that go beyond Ada.

"Beyond Ada" sounds like wavy escape rhetorics:
Since the inception of what is now Ada, it was
pronouncedly clear that Ada is adressing real
computer systems and their hardware properties and
Ada was and is expressly connected to other standards.

Both, real computer systems and other standards
do *not* *at* *all* suggest the use of predefined
named types from package Standard for all your integer
needs, since Ada is smarter than that---unless teachers
prohibit the use of its extraordinary base type system!

See http://www.stsc.hill.af.mil/crosstalk/2000/08/mccormick.html
for the huge value attributable to a decent base type system:

"It was the accurate modeling of scalar quantities that
 contributed the most to Ada's success in this course.
 This is consistent with studies done on the nature of
 wicked bugs in software [5] where nearly 80 percent
 of programming errors in the C/C++ programs studied were
 a result of problems with scalars.

"[5] Eisenstadt, M. (1997). My Hairiest Bug War Stories.
 Communications of the ACM, 40, 30-37."

where "modeling of scalar quantities" is

"Modeling of scalar objects.
-- Strong typing.
-- Range constraints.
-- Enumeration types."

Aou suggest we should instead use implementation defined
types of unknown sizes?


>         But Ada also, use standards for it types, "Integer", and "Float', with 
> their associate subtypes.  One reason but not the only reason for the range of 
> these built-in types are the hardware.

Each user defined integer type, including operations
and objects, is translated giving proper attention to hardware,



>         First, if this could happen the RM would need a MAJOR overhaul. 
> It would be easier to create a new language. Because both types are used 
> throughout the RM defined packages.

As has been said, use types from the Standard package
if and only if using the standard library.
Use package Interfaces.* if and only if interfacing
to language external facilities.


>         Second, the predefined types allow for the program to be more portable, 
> because a users type might not be accepted on the new system.

Portability through *avoiding* type definitions seems a
simplicissimus' argument, pardon me.  Worse, it's a lure,
see Randy Brukardt's report.  The statement

  S : String (Positive'First .. Positive'Last / 2);

is largely unpredictable as regards portability from one
machine/RTS to another. So where is your portability?
If Positive happens to be a type for adressing 2**15 - 1
components, your program might run fine in one environment.
Once you port it to GNAT, say, you might be experiencing
all kinds of trouble!

If you really want programmers to

(a) use machine properties, or
(b) express maximally extensive types, for example,

then make them say so! Ada has the necessary bounds defined
for this kind of type definitions:

   type My_Portability_Type is
     range 0 .. Integer'Min(System.Max_Int, System.Memory_Size);

    -- use whatever range is possible

This *cannot* be achieved by relying on Standard.Integer.

 But using the
> standards or creating a subtype from the standards is better. An example is:
> 
>     type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ;
> 
> which is a valid Ada statement but in a 32-bit and most 64-bit system this 
> type is not allowed. You would need to use a special array or record type that 
> is based on the universal-integer or CPU and define the operations in a math 
> package or packages. There are a few special scientific projects that could 
> use that type of maybe even a larger type like 1024-bit, but there's not 
> enough applications for most to spend their time in creating such a package.  
> Normally, its the scientist that ask for help that developes such packages for 
> his project and only for his project and then sets the big price tag for others 
> that package.
> 
>         Then third, is without standards types like "Integer" and "Float" how 
> would the system work.  Using Ada, define a "=" or "*" without using the 
> universal-integer and universal-real types or there operations.

No one *ever* said something about removing the predefined
anonymous types universal_integer and universal_real
*needed* for defining integer types!
This and other claims have been adressed; have the postings
slipped your attention by any chance?




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

* Re: Learning Ada (Was: unsigned type)
  2009-07-06 10:53                   ` Learning Ada (Was: unsigned type) Georg Bauhaus
@ 2009-07-06 19:34                     ` anon
  2009-07-06 20:29                       ` Learning Ada Albrecht Käfer
                                         ` (2 more replies)
  0 siblings, 3 replies; 152+ messages in thread
From: anon @ 2009-07-06 19:34 UTC (permalink / raw)


Who said remove the "the universal types aka the "universal_integer" and 
"universal_real"? Well,

    From: Jacob Sparre Andersen <sparre@nbi.dk>
    Subject: Learning Ada (Was: unsigned type)
    Date: 03 Jul 2009 09:12:51 +0200

    "It might be to push things a bit too far, but I think it would be
     beneficial, if the types Float and Integer were removed from the
     language."

That suggests to anyone that read the statement that he thinks Ada would be 
better off if the "Integer" and "Float" types were remove. And like I said 
it would cause a MAJOR overhaul of the RM to the point that it would be 
easier to create a new language.

A simple reason is that the "Integer" and "Float" are defined in the Standards 
package RM A.1 ( 11 .. 12 ) and  RM A.1 ( 20 .. 21 ). And the comments declare 
the "Integer" basically as the "universal type is universal_integer" and the
"Float" basically as the "universal type is universal_real".  So, when 
"Jacob Sparre Andersen" suggested removing these types he is in a sense 
suggesting pulling the "universal types" aka removing the universal_integer" 
and "universal_real" from Ada. 


As for Portability!

Portability is easy if you use the built-in standards. Like going from a 
CRAY, VAX, IBM and a LLNL super computer (CPU was unknown for the 
project) using, a mixer of programs written in Ada 83 and Ada 95 
specification, with no modification within the used specification. That is,
using either Ada 83 or 95 a program was written for one vendor and 
then compiled for the other 4 system without any Ada statements modifications.
The only allowable change was to programs and its packages file names based 
on system to be compiled.  The result of project was its all in the way 
a person programs with Ada and if they limit the usage of external (non-RM) 
packages. But portability can be extended to non-RM packages if Ada 
programmer use other standards like, in today programs using openGL 
or SDL for a graphic package instead of direct control of the OS window's 
environment.

Now, A integer may change it range when switching from a 16-bit system to a 
64-bit system, but the 16-bit code will work because the range of a 16-bit 
integer is a subrange of a 64-bit integer. Else, throw the CPU and the 
programmer out the window. Yes, a programmer can make a misstate that 
causes error, but that not Ada fault. it time to replace that bad programmer.


A little food for Randy Brukardt report and something he said a few week 
back.

Except for the "gigi" code (a-trans.c) which requires the GCC tree 
structures, the complete GNAT system can be compile on Randy Brukardt's 
janus Ada.  And I mean even the GNAT GPL 2009 can be compiled, that 
portability that a programmer can be proud of. And the reason one can do 
this is Adacore wrote GNAT initial using Ada 83 specs and later they 
might have added a few Ada 95 type statements. It would be true portability 
if the GNAT's "gigi" routine was written in Ada and included a few Ada 
packages for the tree structures to replace the GCC's C version.  Now, 
where's that Ada 95/2005 only version of the "c2ada" program, "simon.j.wright"? 

So, true portability is up to the programmer. Write the code with portability 
in mind. and the programmer can do it! But will he or will he write trashy C 
like code. The decision might be away to help keep there job. 




In <4a51d78d$0$30227$9b4e6d93@newsspool1.arcor-online.net>, Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:
>anon schrieb:
>> Wrong!
>>         I was not talking about the Ada Statements "Type" or "Subtype" but 
>> true Standards that go beyond Ada.
>
>"Beyond Ada" sounds like wavy escape rhetorics:
>Since the inception of what is now Ada, it was
>pronouncedly clear that Ada is adressing real
>computer systems and their hardware properties and
>Ada was and is expressly connected to other standards.
>
>Both, real computer systems and other standards
>do *not* *at* *all* suggest the use of predefined
>named types from package Standard for all your integer
>needs, since Ada is smarter than that---unless teachers
>prohibit the use of its extraordinary base type system!
>
>See http://www.stsc.hill.af.mil/crosstalk/2000/08/mccormick.html
>for the huge value attributable to a decent base type system:
>
>"It was the accurate modeling of scalar quantities that
> contributed the most to Ada's success in this course.
> This is consistent with studies done on the nature of
> wicked bugs in software [5] where nearly 80 percent
> of programming errors in the C/C++ programs studied were
> a result of problems with scalars.
>
>"[5] Eisenstadt, M. (1997). My Hairiest Bug War Stories.
> Communications of the ACM, 40, 30-37."
>
>where "modeling of scalar quantities" is
>
>"Modeling of scalar objects.
>-- Strong typing.
>-- Range constraints.
>-- Enumeration types."
>
>Aou suggest we should instead use implementation defined
>types of unknown sizes?
>
>
>>         But Ada also, use standards for it types, "Integer", and "Float', with 
>> their associate subtypes.  One reason but not the only reason for the range of 
>> these built-in types are the hardware.
>
>Each user defined integer type, including operations
>and objects, is translated giving proper attention to hardware,
>
>
>
>>         First, if this could happen the RM would need a MAJOR overhaul. 
>> It would be easier to create a new language. Because both types are used 
>> throughout the RM defined packages.
>
>As has been said, use types from the Standard package
>if and only if using the standard library.
>Use package Interfaces.* if and only if interfacing
>to language external facilities.
>
>
>>         Second, the predefined types allow for the program to be more portable, 
>> because a users type might not be accepted on the new system.
>
>Portability through *avoiding* type definitions seems a
>simplicissimus' argument, pardon me.  Worse, it's a lure,
>see Randy Brukardt's report.  The statement
>
>  S : String (Positive'First .. Positive'Last / 2);
>
>is largely unpredictable as regards portability from one
>machine/RTS to another. So where is your portability?
>If Positive happens to be a type for adressing 2**15 - 1
>components, your program might run fine in one environment.
>Once you port it to GNAT, say, you might be experiencing
>all kinds of trouble!
>
>If you really want programmers to
>
>(a) use machine properties, or
>(b) express maximally extensive types, for example,
>
>then make them say so! Ada has the necessary bounds defined
>for this kind of type definitions:
>
>   type My_Portability_Type is
>     range 0 .. Integer'Min(System.Max_Int, System.Memory_Size);
>
>    -- use whatever range is possible
>
>This *cannot* be achieved by relying on Standard.Integer.
>
> But using the
>> standards or creating a subtype from the standards is better. An example is:
>> 
>>     type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ;
>> 
>> which is a valid Ada statement but in a 32-bit and most 64-bit system this 
>> type is not allowed. You would need to use a special array or record type that 
>> is based on the universal-integer or CPU and define the operations in a math 
>> package or packages. There are a few special scientific projects that could 
>> use that type of maybe even a larger type like 1024-bit, but there's not 
>> enough applications for most to spend their time in creating such a package.  
>> Normally, its the scientist that ask for help that developes such packages for 
>> his project and only for his project and then sets the big price tag for others 
>> that package.
>> 
>>         Then third, is without standards types like "Integer" and "Float" how 
>> would the system work.  Using Ada, define a "=" or "*" without using the 
>> universal-integer and universal-real types or there operations.
>
>No one *ever* said something about removing the predefined
>anonymous types universal_integer and universal_real
>*needed* for defining integer types!
>This and other claims have been adressed; have the postings
>slipped your attention by any chance?
>




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

* Re: unsigned type
  2009-06-29 13:36     ` Rob Solomon
                         ` (3 preceding siblings ...)
  2009-06-29 15:37       ` unsigned type Adam Beneschan
@ 2009-07-06 20:20       ` Dave
  4 siblings, 0 replies; 152+ messages in thread
From: Dave @ 2009-07-06 20:20 UTC (permalink / raw)


On Jun 29, 9:36 am, Rob Solomon <use...@drrob1-noreply.com> wrote:
> I was able to use the Natural and Positive.  
>
> Now I'm trying to understand Mod types.
>
> I tried this:
> type card31 is mod 2_147_483_648;
> type card32 is mod 4_294_967_296;
> c31 : Card31;
> c32: Card32;
> LI : Long_Integer;
> and
>
> LI := Long_Integer(c32);
>
> How to I output c31 and c32?  Modula-2 uses WriteCard or CardToString
> and WriteString
>
> I tried using Put, but I got an error saying that correct procedure
> could not be found, or something like that.
>
> Put(LI) works until the value of LI > 2**31, even for c32.
>
> Thanks for helping
> --rob
>
> On Sun, 28 Jun 2009 19:54:28 +0000 (UTC), tmo...@acm.org wrote:
> >>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT
> >>compiler.  I know Ada does not have a type CARDINAL, but I thought it
> >>had a type Unsigned.
>
> >Ada's equivalent is Natural.  If
> >  Lowest : Natural := 0;
> >  Highest : Natural := Natural'last;
> >then
> >  Lowest  := Lowest-1;  -- will raise an exception
> >  Highest := Highest+1; -- ditto
>
> >(Note that Gnat by default is not a legal Ada compiler because it doesn't
> >check for and raise the exception.  You need a command line parameter
> >-gnato to make it act like Ada.)
>
> >The standard Ada package Interfaces has hardware-oriented types
> >Unsigned_8, Unsigned_16, etc but those are modular types so if
> >  Empty_Word : Interfaces.Unsigned_16 := 0;
> >  Full_Byte  : Interfaces.Unsigned_8 := 255;
> >then
> >  Empty_Word-1 will be 65535.
> >  Full_Byte+1 will be 0.
> >with no exceptions raised.
>
> >You can also declare your own application oriented non-negative types
> >  type Ratings is range 1 .. 10;
> >or modular types
> >  type Degrees is mod 360;  -- 0 .. 359 wrapping around
>
>

I'm an Ada-nub myself, but...
You could use c31'Image(A_c31_Type): be aware that Type'Image may put/
often puts a space or spaces in front of the string it generates.
More experienced Ada programmers will likely be able to provide a
better answer.



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

* Re: Learning Ada
  2009-07-06  6:18                       ` AdaMagica
  2009-07-06  7:47                         ` Jean-Pierre Rosen
@ 2009-07-06 20:21                         ` anon
  2009-07-06 21:08                           ` Georg Bauhaus
  2009-07-06 22:43                           ` Frank J. Lhota
  1 sibling, 2 replies; 152+ messages in thread
From: anon @ 2009-07-06 20:21 UTC (permalink / raw)


Yes, I did redefine apart of Standard. Found this out back in the mid 1990 
while testing GNAT 3.0x for a number of projects. Its also, one way (not the 
best, but it is quick) of porting code from a 32-bit system down to a 16 or 
8 bit system. Like using Intel Core i7 system to write code for an Intel 
8086 system, which can use the same basic (non-protective mode) 
instruction set. 

Also, rewriting any Ada package is allowable within the scope of the RM 
(in some implementation it maybe required). And if I add a body for the 
Standard package and uncommented the an operators I could of made the 
operator do what I wanted it to do. Like having all Boolean operators 
return FALSE. 

This process does not hide the built-in Standard package, its still there for 
the system to handle the other types, such as the Character or 
Wide_Character set, which can be a headache to define.


In <ba7f8fc3-e386-49cc-a1fb-e53f7e1f04bf@d32g2000yqh.googlegroups.com>, AdaMagica <christoph.grein@eurocopter.com> writes:
>Oh my dear anon, you are so wrong again.
>
>> package STANDARD is
>>
>> =A0 -- The universal type universal_integer is predefined. =A0
>>
>> =A0 type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
>>
>> end STANDARD;
>
>You do *not* redefine Standard with this declaration, you simply hide
>it.
>
>with Standard;
>
>procedure Temp is  -- Here you will get into troubled water.
>
>  X: Integer;  -- this is still the integer from the predefined
>package Standard
>  Y: STANDARD.Integer;  -- this is your INTEGER
>
>  use Standard;
>
>  Z: Integer :=3D 2;  -- oh lord, what's this now?
>
>  -- I'm not sure and I'm reluctant to do the RM exegesis to find out.
>I *guess* it's your INTEGER;
>
>  I: Integer :=3D Z**3;  -- subtype of 3 is still the Integer defined in
>                       -- the predefined Standard you've hidden
>  J: Integer :=3D Z**Z;  -- This should then be illegal because the
>subtype of the right operand of **
>                       -- must be the one from the hidden Standard.
>
>end Temp;
>
>Point is: You cannot redefine Standard! Full stop.
>
>I invite you to find the relevant paragraphs in the RM which state
>what will happen when you define a package named Standard.
>
>And please be careful to not mix up a subtype and the type of the
>subtype and the type of numeric literals. They are all different.




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

* Re: Learning Ada
  2009-07-06 19:34                     ` anon
@ 2009-07-06 20:29                       ` Albrecht Käfer
  2009-07-06 21:04                       ` Learning Ada (Was: unsigned type) Georg Bauhaus
  2009-07-07 19:25                       ` sjw
  2 siblings, 0 replies; 152+ messages in thread
From: Albrecht Käfer @ 2009-07-06 20:29 UTC (permalink / raw)


anon schrieb:
> Now, A integer may change it range when switching from a 16-bit system to a
> 64-bit system, but the 16-bit code will work because the range of a 16-bit
> integer is a subrange of a 64-bit integer. Else, throw the CPU and the
> programmer out the window. Yes, a programmer can make a misstate that
> causes error, but that not Ada fault. it time to replace that bad programmer.

You're forgetting the embedded market. There may be good reasons to
downgrade from a 32-bit to a 16-bit (or even 8-bit) system. Power
consumption, resistance to radiation or simply the price come to mind.


Albrecht



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

* Re: Learning Ada (Was: unsigned type)
  2009-07-06 19:34                     ` anon
  2009-07-06 20:29                       ` Learning Ada Albrecht Käfer
@ 2009-07-06 21:04                       ` Georg Bauhaus
  2009-07-07 19:25                       ` sjw
  2 siblings, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-06 21:04 UTC (permalink / raw)


anon wrote:
> the [RM] comments declare 
> the "Integer" basically as the "universal type is universal_integer" and the
> "Float" basically as the "universal type is universal_real".

Do they?  You mean, Humpty Dumpty is here again? ;-)


> Now, A integer may change it range when switching from a 16-bit system to a 
> 64-bit system, but the 16-bit code will work because the range of a 16-bit 
> integer is a subrange of a 64-bit integer.

Do you mean that every mention of Positive'Range, paradigmatically,
will not be a problem when going from a 16bit sized Positive range
to a 64bit sized Positive range?

Did you have a minute to consider the example given,

  S : String (Positive'First .. Positive'Last / 2);

on an 8GB RAM 64 bit system with 64bit sized Positive range?
It *won't* work.   Standard.Integer *did* create problems
when porting to other sizes, that's how I understand what
Randy Brukardt has said.

There exist algorithms that will work when the bit size
of Integer increases.  But that's not relevant.
Because Ada allows us to make this requirement
explicit by declaring, that an algorithm shall profit
from larger integer types:

  type Big_Num is range 0 .. System.Max_Int;

This does what sets Ada apart from most other languages:
the type distinguished application integer types and
ubiquitous library integer types.  A Good Thing when porting
a program.

[Other random remarks (really) and miscellanea portraying
knowledge of many Ada compilers skipped.]



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

* Re: Learning Ada
  2009-07-06 20:21                         ` anon
@ 2009-07-06 21:08                           ` Georg Bauhaus
  2009-07-06 22:43                           ` Frank J. Lhota
  1 sibling, 0 replies; 152+ messages in thread
From: Georg Bauhaus @ 2009-07-06 21:08 UTC (permalink / raw)


anon wrote:
> Yes, I did redefine apart of Standard. Found this out back in the mid 1990 
> while testing GNAT 3.0x for a number of projects. Its also, one way (not the 
> best, but it is quick) of porting code from a 32-bit system down to a 16 or 
> 8 bit system. Like using Intel Core i7 system to write code for an Intel 
> 8086 system, which can use the same basic (non-protective mode) 
> instruction set. 

So you are proving our point that using Standard.Integer
has created a need to replace Standard.Integer with a
different integer type that helps porting?

Wouldn't it have been better if the programmers
had not used Standard.Integer in the first place,
where possible?



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

* Re: Learning Ada
  2009-07-06 20:21                         ` anon
  2009-07-06 21:08                           ` Georg Bauhaus
@ 2009-07-06 22:43                           ` Frank J. Lhota
  2009-07-09 22:28                             ` anon
  1 sibling, 1 reply; 152+ messages in thread
From: Frank J. Lhota @ 2009-07-06 22:43 UTC (permalink / raw)


anon wrote:
> Yes, I did redefine apart of Standard. Found this out back in the mid 1990 
> while testing GNAT 3.0x for a number of projects. Its also, one way (not the 
> best, but it is quick) of porting code from a 32-bit system down to a 16 or 
> 8 bit system. Like using Intel Core i7 system to write code for an Intel 
> 8086 system, which can use the same basic (non-protective mode) 
> instruction set. 

No, you did not re-define a part of Standard. Keep in mind that all of 
the compilation units you write is enclosed in the Standard package. As 
a result, every Ada name can be expanded to something of the form 
"Standard.*".

When you wrote the package Standard as presented above, what you really 
did was add a package named Standard *within* the pre-defined package 
Standard, i.e. the result was something like this:

-- Ada LRM Standard
package Standard is

     ...
     type Integer is range ...;
     ...

     -- Your Standard package
     package Standard is
         type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
     end Standard;

end Standard;

In other words, you've created the new type Standard.Standard.Integer, 
which is a separate type from Standard.Integer.

> Also, rewriting any Ada package is allowable within the scope of the RM 
> (in some implementation it maybe required). And if I add a body for the 
> Standard package and uncommented the an operators I could of made the 
> operator do what I wanted it to do. Like having all Boolean operators 
> return FALSE. 

LRM A.2 (4) specifically prohibit the compilation of a child of package 
Ada in standard mode. I believe that some implementations would squawk 
if you tried to replace parts of System, especially since doing so could 
break other pre-defined units.

> This process does not hide the built-in Standard package, its still there for 
> the system to handle the other types, such as the Character or 
> Wide_Character set, which can be a headache to define.

Well, it does create some confusion. I would definitely *not* recommend 
naming a unit Standard.

> 
> In <ba7f8fc3-e386-49cc-a1fb-e53f7e1f04bf@d32g2000yqh.googlegroups.com>, AdaMagica <christoph.grein@eurocopter.com> writes:
>> Oh my dear anon, you are so wrong again.
>>
>>> package STANDARD is
>>>
>>> =A0 -- The universal type universal_integer is predefined. =A0
>>>
>>> =A0 type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
>>>
>>> end STANDARD;
>> You do *not* redefine Standard with this declaration, you simply hide
>> it.
>>
>> with Standard;
>>
>> procedure Temp is  -- Here you will get into troubled water.
>>
>>  X: Integer;  -- this is still the integer from the predefined
>> package Standard
>>  Y: STANDARD.Integer;  -- this is your INTEGER
>>
>>  use Standard;
>>
>>  Z: Integer :=3D 2;  -- oh lord, what's this now?
>>
>>  -- I'm not sure and I'm reluctant to do the RM exegesis to find out.
>> I *guess* it's your INTEGER;
>>
>>  I: Integer :=3D Z**3;  -- subtype of 3 is still the Integer defined in
>>                       -- the predefined Standard you've hidden
>>  J: Integer :=3D Z**Z;  -- This should then be illegal because the
>> subtype of the right operand of **
>>                       -- must be the one from the hidden Standard.
>>
>> end Temp;
>>
>> Point is: You cannot redefine Standard! Full stop.
>>
>> I invite you to find the relevant paragraphs in the RM which state
>> what will happen when you define a package named Standard.
>>
>> And please be careful to not mix up a subtype and the type of the
>> subtype and the type of numeric literals. They are all different.
> 


-- 
"All things extant in this world,
Gods of Heaven, gods of Earth,
Let everything be as it should be;
Thus shall it be!"
- Magical chant from "Magical Shopping Arcade Abenobashi"

"Drizzle, Drazzle, Drozzle, Drome,
Time for this one to come home!"
- Mr. Wizard from "Tooter Turtle"



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

* Re: Learning Ada (Was: unsigned type)
  2009-07-05 23:21                 ` anon
                                     ` (2 preceding siblings ...)
  2009-07-06 10:53                   ` Learning Ada (Was: unsigned type) Georg Bauhaus
@ 2009-07-06 23:15                   ` Randy Brukardt
  2009-07-07 15:29                     ` Adam Beneschan
  3 siblings, 1 reply; 152+ messages in thread
From: Randy Brukardt @ 2009-07-06 23:15 UTC (permalink / raw)


"anon" <anon@anon.org> wrote in message 
news:4Aa4m.421894$4m1.207252@bgtnsc05-news.ops.worldnet.att.net...
...
>        But Ada also, use standards for it types, "Integer", and "Float', 
> with
> their associate subtypes.  One reason but not the only reason for the 
> range of
> these built-in types are the hardware.  If the hardware uses 32-bits 
> integers
> then the Ada "Integer" is based on 32-bit.

This statement is not true. For instance, for Janus/Ada 95 on Windows, type 
Integer is 16-bits. (We chose that to remain compatible with our earlier 
compilers.)

All the standard requires is that Integer is 16-bits, and that Long_Integer 
(if it exists) is longer than Integer.

Thus, type Integer means vastly different things when compiled with 
Janus/Ada on Windows as compared to when compiled with Gnat on Windows. If 
you need values up to 1 million, you will have no portability at all if you 
use type Integer.

OTOH,
                       type My_Int is range 0 .. 1_000_000;

will work properly on both compilers (and most likely, on any other Ada 
compiler for Windows).

So which is more portable??

                                 Randy.





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

* Re: Learning Ada (Was: unsigned type)
  2009-07-06 23:15                   ` Randy Brukardt
@ 2009-07-07 15:29                     ` Adam Beneschan
  2009-07-09  0:15                       ` Randy Brukardt
  0 siblings, 1 reply; 152+ messages in thread
From: Adam Beneschan @ 2009-07-07 15:29 UTC (permalink / raw)


On Jul 6, 4:15 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:

> All the standard requires is that Integer is 16-bits

You mean "at least 16 bits", right?

>, and that Long_Integer
> (if it exists) is longer than Integer.

I think that should be "at least as long"... (3.5.4(25): "the range of
Integer should be no wider than that of Long_Integer").  Of course, if
Integer is only 16 bits then Long_Integer must be longer (since
Long_Integer must be at least 32 bits), but if Integer is 32 bits then
it appears OK if Long_Integer is the same size as Integer.

                                  -- Adam




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

* Re: Learning Ada (Was: unsigned type)
  2009-07-06 19:34                     ` anon
  2009-07-06 20:29                       ` Learning Ada Albrecht Käfer
  2009-07-06 21:04                       ` Learning Ada (Was: unsigned type) Georg Bauhaus
@ 2009-07-07 19:25                       ` sjw
  2 siblings, 0 replies; 152+ messages in thread
From: sjw @ 2009-07-07 19:25 UTC (permalink / raw)


On Jul 6, 8:34 pm, a...@anon.org (anon) wrote:

>                             Now,
> where's that Ada 95/2005 only version of the "c2ada" program, "simon.j.wright"?

What on earth are you on about? no, wait a moment, I don't care .. I
do wish Google news had a killfile



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

* Re: Learning Ada (Was: unsigned type)
  2009-07-07 15:29                     ` Adam Beneschan
@ 2009-07-09  0:15                       ` Randy Brukardt
  2009-07-09 15:26                         ` Adam Beneschan
  0 siblings, 1 reply; 152+ messages in thread
From: Randy Brukardt @ 2009-07-09  0:15 UTC (permalink / raw)


"Adam Beneschan" <adam@irvine.com> wrote in message 
news:c5a3eb71-0395-4727-b4dd-826b1196d262@m3g2000pri.googlegroups.com...
>On Jul 6, 4:15 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
>
>> All the standard requires is that Integer is 16-bits
>
>You mean "at least 16 bits", right?

Yes, of course.

>>, and that Long_Integer
>> (if it exists) is longer than Integer.
>
>I think that should be "at least as long"... (3.5.4(25): "the range of
>Integer should be no wider than that of Long_Integer").  Of course, if
>Integer is only 16 bits then Long_Integer must be longer (since
>Long_Integer must be at least 32 bits), but if Integer is 32 bits then
>it appears OK if Long_Integer is the same size as Integer.

You're correct of course, although I think it is pretty dubious to have a 
Long_Integer type with the same range as Integer. Probably it is allowed to 
support another form of compatibility (so that the name exists), but it is 
always better to not use the type in the first place (unlike Integer, you're 
never required to use Long_Integer).

                           Randy.


                                  -- Adam





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

* Re: Learning Ada (Was: unsigned type)
  2009-07-09  0:15                       ` Randy Brukardt
@ 2009-07-09 15:26                         ` Adam Beneschan
  0 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-07-09 15:26 UTC (permalink / raw)


On Jul 8, 5:15 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> "Adam Beneschan" <a...@irvine.com> wrote in message
>
> news:c5a3eb71-0395-4727-b4dd-826b1196d262@m3g2000pri.googlegroups.com...
>
> >On Jul 6, 4:15 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
>
> >> All the standard requires is that Integer is 16-bits
>
> >You mean "at least 16 bits", right?
>
> Yes, of course.
>
> >>, and that Long_Integer
> >> (if it exists) is longer than Integer.
>
> >I think that should be "at least as long"... (3.5.4(25): "the range of
> >Integer should be no wider than that of Long_Integer").  Of course, if
> >Integer is only 16 bits then Long_Integer must be longer (since
> >Long_Integer must be at least 32 bits), but if Integer is 32 bits then
> >it appears OK if Long_Integer is the same size as Integer.
>
> You're correct of course, although I think it is pretty dubious to have a
> Long_Integer type with the same range as Integer. Probably it is allowed to
> support another form of compatibility (so that the name exists), but it is
> always better to not use the type in the first place (unlike Integer, you're
> never required to use Long_Integer).

The reason I thought of for having a compiler vendor define Integer
and Long_Integer to be the same size was to assist users who are
porting from one target to another, which I think is what you were
hinting at.  I can imagine a word-addressable target with a 32-bit
word size, so that it wouldn't make sense to define Integer as less
than 32 bits, but they also might not want to make Long_Integer 64
bits because the operations would involve extra overhead (multiple add-
with-carry instructions) that users wouldn't want---and of course they
wouldn't want to eliminate Long_Integer entirely.  Of course,
processors like that may exist only in the textbooks I had to learn
from 30 years ago. :)

Also, it may be true that users who needed the ability to write
portable programs shouldn't have been using the standard types,
especially Long_Integer, in the first place.  But as compiler vendors,
our job is to help our customers accomplish what they need to
accomplish, not to sit in judgment of them and say "You're not allowed
to use our product" if they're code isn't 100% up to our exacting
standards for writing portable code.  So instead, we try to write our
compilers in the way that will be most helpful.  If in some
(hypothetical) instances it means making Long_Integer the same size as
Integer, then fine.

                                       -- Adam



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

* Re: Learning Ada
  2009-07-06 22:43                           ` Frank J. Lhota
@ 2009-07-09 22:28                             ` anon
  2009-07-10  6:23                               ` AdaMagica
  0 siblings, 1 reply; 152+ messages in thread
From: anon @ 2009-07-09 22:28 UTC (permalink / raw)


If Ada RM A.2 ( 4 ), applied here, then Adacore / GNAT would not allow one 
to compile the a Standard package. When compiling the Ada.* you must use 
"-gnatpg", command option, but compiling the Standard package is as easy 
as compiling any non-vendor or Ada package.

Actually I wrote the complete Standards package for both Ada 83 and 95 
including a body that use System.Machine_Code for the routines base on the 
Ada 83 and Ada 95 specs.  

And these routines could be used for embeded processors, but the main code 
would still be generated by the GCC backend.

In <h2tun7$bpp$1@news.albasani.net>, "Frank J. Lhota" <FrankLho.NOSPAM@rcn.com> writes:
>anon wrote:
>> Yes, I did redefine apart of Standard. Found this out back in the mid 1990 
>> while testing GNAT 3.0x for a number of projects. Its also, one way (not the 
>> best, but it is quick) of porting code from a 32-bit system down to a 16 or 
>> 8 bit system. Like using Intel Core i7 system to write code for an Intel 
>> 8086 system, which can use the same basic (non-protective mode) 
>> instruction set. 
>
>No, you did not re-define a part of Standard. Keep in mind that all of 
>the compilation units you write is enclosed in the Standard package. As 
>a result, every Ada name can be expanded to something of the form 
>"Standard.*".
>
>When you wrote the package Standard as presented above, what you really 
>did was add a package named Standard *within* the pre-defined package 
>Standard, i.e. the result was something like this:
>
>-- Ada LRM Standard
>package Standard is
>
>     ...
>     type Integer is range ...;
>     ...
>
>     -- Your Standard package
>     package Standard is
>         type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
>     end Standard;
>
>end Standard;
>
>In other words, you've created the new type Standard.Standard.Integer, 
>which is a separate type from Standard.Integer.
>
>> Also, rewriting any Ada package is allowable within the scope of the RM 
>> (in some implementation it maybe required). And if I add a body for the 
>> Standard package and uncommented the an operators I could of made the 
>> operator do what I wanted it to do. Like having all Boolean operators 
>> return FALSE. 
>
>LRM A.2 (4) specifically prohibit the compilation of a child of package 
>Ada in standard mode. I believe that some implementations would squawk 
>if you tried to replace parts of System, especially since doing so could 
>break other pre-defined units.
>
>> This process does not hide the built-in Standard package, its still there for 
>> the system to handle the other types, such as the Character or 
>> Wide_Character set, which can be a headache to define.
>
>Well, it does create some confusion. I would definitely *not* recommend 
>naming a unit Standard.
>
>> 
>> In <ba7f8fc3-e386-49cc-a1fb-e53f7e1f04bf@d32g2000yqh.googlegroups.com>, AdaMagica <christoph.grein@eurocopter.com> writes:
>>> Oh my dear anon, you are so wrong again.
>>>
>>>> package STANDARD is
>>>>
>>>> =A0 -- The universal type universal_integer is predefined. =A0
>>>>
>>>> =A0 type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;
>>>>
>>>> end STANDARD;
>>> You do *not* redefine Standard with this declaration, you simply hide
>>> it.
>>>
>>> with Standard;
>>>
>>> procedure Temp is  -- Here you will get into troubled water.
>>>
>>>  X: Integer;  -- this is still the integer from the predefined
>>> package Standard
>>>  Y: STANDARD.Integer;  -- this is your INTEGER
>>>
>>>  use Standard;
>>>
>>>  Z: Integer :=3D 2;  -- oh lord, what's this now?
>>>
>>>  -- I'm not sure and I'm reluctant to do the RM exegesis to find out.
>>> I *guess* it's your INTEGER;
>>>
>>>  I: Integer :=3D Z**3;  -- subtype of 3 is still the Integer defined in
>>>                       -- the predefined Standard you've hidden
>>>  J: Integer :=3D Z**Z;  -- This should then be illegal because the
>>> subtype of the right operand of **
>>>                       -- must be the one from the hidden Standard.
>>>
>>> end Temp;
>>>
>>> Point is: You cannot redefine Standard! Full stop.
>>>
>>> I invite you to find the relevant paragraphs in the RM which state
>>> what will happen when you define a package named Standard.
>>>
>>> And please be careful to not mix up a subtype and the type of the
>>> subtype and the type of numeric literals. They are all different.
>> 
>
>
>-- 
>"All things extant in this world,
>Gods of Heaven, gods of Earth,
>Let everything be as it should be;
>Thus shall it be!"
>- Magical chant from "Magical Shopping Arcade Abenobashi"
>
>"Drizzle, Drazzle, Drozzle, Drome,
>Time for this one to come home!"
>- Mr. Wizard from "Tooter Turtle"




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

* Re: Learning Ada
  2009-07-09 22:28                             ` anon
@ 2009-07-10  6:23                               ` AdaMagica
  0 siblings, 0 replies; 152+ messages in thread
From: AdaMagica @ 2009-07-10  6:23 UTC (permalink / raw)


On 10 Jul., 00:28, a...@anon.org (anon) wrote:
> If Ada RM A.2 ( 4 ), applied here, then Adacore / GNAT would not allow one
> to compile the a Standard package. When compiling the Ada.* you must use
> "-gnatpg", command option, but compiling the Standard package is as easy
> as compiling any non-vendor or Ada package.

A.2(4) In the standard mode, it is illegal to compile a child of
package Ada.

So what on earth are you talking about? Your Standard package is not a
child of Ada nor is the RM package Standard a child of Ada.

Any user-written library unit, so also your Standard, can ve viewed as
a child of the RM Standard, as Frank Lhota has explained. No one
claimed that it was illegal in standard mode to compile a package
called Standard.

Do you ever take the time to understand other's posts?



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

* Re: unsigned type
  2009-06-29  8:00         ` anon
  2009-06-29  9:56           ` Jean-Pierre Rosen
  2009-06-29 10:25           ` Georg Bauhaus
@ 2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
  2009-07-11 17:18             ` sjw
  2009-07-11 20:20             ` anon
  2009-07-11 14:43           ` Hibou57 (Yannick Duchêne)
  3 siblings, 2 replies; 152+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-07-11 14:40 UTC (permalink / raw)


On 29 juin, 10:00, a...@anon.org (anon) wrote:
>                           --  'A' is a zero length string, A'Last = 0, and
>                           --  put_line  ( A ( A'First .. A'Last ) ) ;
>                           --  does not raise an Constraint_Error even though in
>                           --  this case it translate to:
>                           --  put_line  ( A ( 0 .. 0 ) ) ;
>   A : String := ""        ;
> Since you can have zero length string , the index is Natual instead of Positive,
> because zero is in Natural but is not define in Positive. Even though the
> Standard package define String index as a Positive type.

The length of a string is Natural, the index type Positive, as long as
lowest bound is 1.

A zero length string does not have any valid index. Using strings,
unless I can assert the length is greater than zero, I always check
the length before any attemp to use its 'First and 'Last attributes.
Conceptually, when a string is zero length, at least one of its bound
is not in the valid range of its index type, and any way, none of its
bound would be a valid index in the string.

There is a precondition to access both bound or to access element of a
string by index : this precondition as that its length should be
greater than zero.

Printing a zero length string does not imply attempting to print
chracters in index range 1 .. 0, but may be instead properly handled
by simple not accessing the string and simply not printing anything,
providing the length has been previously known to be zero.



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

* Re: unsigned type
  2009-06-29  8:00         ` anon
                             ` (2 preceding siblings ...)
  2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
@ 2009-07-11 14:43           ` Hibou57 (Yannick Duchêne)
  2009-07-11 15:22             ` Albrecht Käfer
  3 siblings, 1 reply; 152+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-07-11 14:43 UTC (permalink / raw)


On 29 juin, 10:00, a...@anon.org (anon) wrote:
>       But most 80286/80386 code using protective mode must have a
>       major rewrite if updating to use the Core 2 dual/quad or Core i7.
What is projective mode please ?



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

* Re: unsigned type
  2009-07-11 14:43           ` Hibou57 (Yannick Duchêne)
@ 2009-07-11 15:22             ` Albrecht Käfer
  0 siblings, 0 replies; 152+ messages in thread
From: Albrecht Käfer @ 2009-07-11 15:22 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) schrieb:
> On 29 juin, 10:00, a...@anon.org (anon) wrote:
>>       But most 80286/80386 code using protective mode must have a
>>       major rewrite if updating to use the Core 2 dual/quad or Core i7.
> What is projective mode please ?

He meant protected mode. The native operating mode (meaning the one they
were supposed to be in most of the time) of all processors from the
80286 to the Pentium 4 and Athlons. Succeded by Long Mode of the AMD64
architecture and whichever 64-bit mode the Itaniums have.


Albrecht



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

* Re: unsigned type
  2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
@ 2009-07-11 17:18             ` sjw
  2009-07-11 18:15               ` Hibou57 (Yannick Duchêne)
  2009-07-11 20:20             ` anon
  1 sibling, 1 reply; 152+ messages in thread
From: sjw @ 2009-07-11 17:18 UTC (permalink / raw)


On Jul 11, 3:40 pm, Hibou57 (Yannick Duchêne)
<yannick_duch...@yahoo.fr> wrote:

> The length of a string is Natural, the index type Positive, as long as
> lowest bound is 1.

The index type of String is always positive!

> Printing a zero length string does not imply attempting to print
> chracters in index range 1 .. 0, but may be instead properly handled
> by simple not accessing the string and simply not printing anything,
> providing the length has been previously known to be zero.

I think this is too restrictive!

This:

with Ada.Text_IO; use Ada.Text_IO;
procedure Zero_Length_String is
   S : String (-5 .. -7) := "";
begin
   Put_Line ("S is """
               & S
               & """, 'First is "
               & Integer'Image (S'First)
               & ", 'Last is "
               & Integer'Image (S'Last));
   Put_Line ("S is """ & S (S'First .. S'Last) & """");
end Zero_Length_String;

results (GNAT GPL 2009) in

$ ./zero_length_string
S is "", 'First is -5, 'Last is -7
S is ""



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

* Re: unsigned type
  2009-07-11 17:18             ` sjw
@ 2009-07-11 18:15               ` Hibou57 (Yannick Duchêne)
  0 siblings, 0 replies; 152+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-07-11 18:15 UTC (permalink / raw)


On 11 juil, 17:22, Albrecht Käfer <albrecht_kae...@yahoo.de> wrote:
> He meant protected mode.
Ah, Ok, the protected mode. Thanks Albrecht

On 11 juil, 19:18, sjw <simon.j.wri...@mac.com> wrote:
> I think this is too restrictive!
Restrictive is safer and helps to be clearer



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

* Re: unsigned type
  2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
  2009-07-11 17:18             ` sjw
@ 2009-07-11 20:20             ` anon
  2009-07-12 17:57               ` Samuel Tardieu
  1 sibling, 1 reply; 152+ messages in thread
From: anon @ 2009-07-11 20:20 UTC (permalink / raw)


Zero length are defined in Ada a null length and the common use in source
code is either a string value of "" or any string with a null range, that is 
where the Upper bounds is less than the lower bound, such as ( 1 .. 0 ) or 
( 5 .. 3 ), but to me the idea that ( 1 .. 0 ) or ( -5 .. -7 ) is a valid null 
string, is wrong.  Both indexes should be of the type positive, which makes 
the ( 1..0 ) that is use in the RM illegal. But some here and the GNAT compiler 
says the ( 1 .. 0 ) and ( -5 .. -7 ) are both valid in the source code.  A 
string with the range of ( -5 .. -7 ) looks like bad C coding anfd that's not
Ada. 

The problem is at runtime the system checks the Lower bounds for a valid 
type first, but it only checks the Upper bound type, after it determines that 
the value is not a null range. So, to the runtime a ( 1 .. -100 ) is a valid 
runtime, and that seams wrong. Especially, since Ada is known for it strong 
"Type Checking" it seams logical to first check both indexes foe a valid type, 
then the null range second. With the third being for a valid subscript range. 

See post "getting back to null range' for an example program.


In <ff104286-de81-4bd3-bfef-70cbae1d16df@v2g2000vbb.googlegroups.com>, =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= <yannick_duchene@yahoo.fr> writes:
>On 29 juin, 10:00, a...@anon.org (anon) wrote:
>>                           --  'A' is a zero length string, A'Last = 0, and
>>                           --  put_line  ( A ( A'First .. A'Last ) ) ;
>>                           --  does not raise an Constraint_Error even though in
>>                           --  this case it translate to:
>>                           --  put_line  ( A ( 0 .. 0 ) ) ;
>>   A : String := ""        ;
>> Since you can have zero length string , the index is Natual instead of Positive,
>> because zero is in Natural but is not define in Positive. Even though the
>> Standard package define String index as a Positive type.
>
>The length of a string is Natural, the index type Positive, as long as
>lowest bound is 1.
>
>A zero length string does not have any valid index. Using strings,
>unless I can assert the length is greater than zero, I always check
>the length before any attemp to use its 'First and 'Last attributes.
>Conceptually, when a string is zero length, at least one of its bound
>is not in the valid range of its index type, and any way, none of its
>bound would be a valid index in the string.
>
>There is a precondition to access both bound or to access element of a
>string by index : this precondition as that its length should be
>greater than zero.
>
>Printing a zero length string does not imply attempting to print
>chracters in index range 1 .. 0, but may be instead properly handled
>by simple not accessing the string and simply not printing anything,
>providing the length has been previously known to be zero.




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

* Re: unsigned type
  2009-07-11 20:20             ` anon
@ 2009-07-12 17:57               ` Samuel Tardieu
  2009-07-12 18:24                 ` AdaMagica
  2009-07-13 22:03                 ` anon
  0 siblings, 2 replies; 152+ messages in thread
From: Samuel Tardieu @ 2009-07-12 17:57 UTC (permalink / raw)


>>>>> "anon" == anon  <anon@anon.org> writes:

anon> But some here and the GNAT compiler says the ( 1 .. 0 ) and ( -5
anon> .. -7 ) are both valid in the source code.  A string with the
anon> range of ( -5 .. -7 ) looks like bad C coding anfd that's not Ada.

The RM says that explicitely:

RM 3.5 (4): "A range has a lower bound and an upper bound and specifies
a subset of the values of some scalar type (the type of the range). A
range with lower bound L and upper bound R is described by ``L
.. R''. If R is less than L, then the range is a null range, and
specifies an empty set of values. Otherwise, the range specifies the
values of the type from the lower bound to the upper bound, inclusive."

RM 3.5 (8): "A range is compatible with a scalar subtype if and only if
it is either a null range or each bound of the range belongs to the
range of the subtype. A range_constraint is compatible with a scalar
subtype if and only if its range is compatible with the subtype."

So 1 .. 0 or -5 .. -7 are null ranges, thus compatible with a Positive
range.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



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

* Re: unsigned type
  2009-07-12 17:57               ` Samuel Tardieu
@ 2009-07-12 18:24                 ` AdaMagica
  2009-07-13 22:03                 ` anon
  1 sibling, 0 replies; 152+ messages in thread
From: AdaMagica @ 2009-07-12 18:24 UTC (permalink / raw)


On 12 Jul., 19:57, Samuel Tardieu <s...@rfc1149.net> wrote:
> >>>>> "anon" == anon  <a...@anon.org> writes:
>
> anon> But some here and the GNAT compiler says the ( 1 .. 0 ) and ( -5
> anon> .. -7 ) are both valid in the source code.  A string with the
> anon> range of ( -5 .. -7 ) looks like bad C coding anfd that's not Ada.
>
> The RM says that explicitely:
>
> RM 3.5 (4): "A range has a lower bound and an upper bound and specifies
> a subset of the values of some scalar type (the type of the range). A
> range with lower bound L and upper bound R is described by ``L
> .. R''. If R is less than L, then the range is a null range, and
> specifies an empty set of values. Otherwise, the range specifies the
> values of the type from the lower bound to the upper bound, inclusive."
>
> RM 3.5 (8): "A range is compatible with a scalar subtype if and only if
> it is either a null range or each bound of the range belongs to the
> range of the subtype. A range_constraint is compatible with a scalar
> subtype if and only if its range is compatible with the subtype."
>
> So 1 .. 0 or -5 .. -7 are null ranges, thus compatible with a Positive
> range.
>
>   Sam
> --
> Samuel Tardieu -- s...@rfc1149.net --http://www.rfc1149.net/

My dear Sam, this is Love's Labour's Lost because this has been
pointed out to anon several times in this discussion - he just won't
listen.



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

* Re: unsigned type
  2009-07-12 17:57               ` Samuel Tardieu
  2009-07-12 18:24                 ` AdaMagica
@ 2009-07-13 22:03                 ` anon
  2009-07-14  7:58                   ` Martin
  1 sibling, 1 reply; 152+ messages in thread
From: anon @ 2009-07-13 22:03 UTC (permalink / raw)


The RM defines, what a "null range" is, but the RM does not say that you must 
first check for "null range" then the type and for a valid range in an array or 
string.  The RM allows any vendor to check the type first before checking for a 
"null range" condition. Or it could be that the RM might assume that subtype 
checking has already been done, because the RM assume that the compiler and 
runtime has check that the bound is a scalar type.

The GNAT compiler will allow any value for a null range but the GNAT runtime 
will not. The GNAT runtime system first checks the lower bound type (for 
Strings the lower bounds must be Positive) then checks for the "null range".  
This should be corrected by either the compiler should be force to at least 
check for a valid lower bound or the runtime system. Or better yet just check 
the type of both bounds first.

And if you compile and execute my test suite program you will see just 
how non-Ada the code becomes when using "null range".  

In <878witokbn.fsf@willow.rfc1149.net>, Samuel Tardieu <sam@rfc1149.net> writes:
>>>>>> "anon" == anon  <anon@anon.org> writes:
>
>anon> But some here and the GNAT compiler says the ( 1 .. 0 ) and ( -5
>anon> .. -7 ) are both valid in the source code.  A string with the
>anon> range of ( -5 .. -7 ) looks like bad C coding anfd that's not Ada.
>
>The RM says that explicitely:
>
>RM 3.5 (4): "A range has a lower bound and an upper bound and specifies
>a subset of the values of some scalar type (the type of the range). A
>range with lower bound L and upper bound R is described by ``L
>... R''. If R is less than L, then the range is a null range, and
>specifies an empty set of values. Otherwise, the range specifies the
>values of the type from the lower bound to the upper bound, inclusive."
>
>RM 3.5 (8): "A range is compatible with a scalar subtype if and only if
>it is either a null range or each bound of the range belongs to the
>range of the subtype. A range_constraint is compatible with a scalar
>subtype if and only if its range is compatible with the subtype."
>
>So 1 .. 0 or -5 .. -7 are null ranges, thus compatible with a Positive
>range.
>
>  Sam
>-- 
>Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/




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

* Re: unsigned type
  2009-07-13 22:03                 ` anon
@ 2009-07-14  7:58                   ` Martin
  2009-07-16 13:54                     ` anon
  0 siblings, 1 reply; 152+ messages in thread
From: Martin @ 2009-07-14  7:58 UTC (permalink / raw)


On Jul 13, 11:03 pm, a...@anon.org (anon) wrote:
> The RM defines, what a "null range" is, but the RM does not say that you must
> first check for "null range" then the type and for a valid range in an array or
> string.  The RM allows any vendor to check the type first before checking for a
> "null range" condition. Or it could be that the RM might assume that subtype
> checking has already been done, because the RM assume that the compiler and
> runtime has check that the bound is a scalar type.

RM 4.1.2(7), 2nd sentence:

"If the slice is not a null slice (a slice where the discrete_range is
a null range), then a check is made that the bounds of the
discrete_range belong to the index range of the array denoted by the
prefix. Constraint_Error is raised if this check fails."

Which bit of 'if' followed by 'then' are you having trouble with?

Cheers
-- Martin




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

* Re: unsigned type
  2009-07-14  7:58                   ` Martin
@ 2009-07-16 13:54                     ` anon
  2009-07-16 14:41                       ` Martin
  0 siblings, 1 reply; 152+ messages in thread
From: anon @ 2009-07-16 13:54 UTC (permalink / raw)


The Slice rule RM 4.1.2 ( 7 ) does not stop a vendor from checking the 
bounds type first. In GNAT, using the last program I posted you will see that 
GNAT, first checks the lower bound type then checks for a "null range". Which 
somewhat goes against the rule RM 4.1.2 ( 7 ).
 
In <72cf874a-ebdc-4a19-9e05-ee9b9a3c245a@l28g2000vba.googlegroups.com>, Martin <martin.dowie@btopenworld.com> writes:
>On Jul 13, 11:03=A0pm, a...@anon.org (anon) wrote:
>> The RM defines, what a "null range" is, but the RM does not say that you =
>must
>> first check for "null range" then the type and for a valid range in an ar=
>ray or
>> string. =A0The RM allows any vendor to check the type first before checki=
>ng for a
>> "null range" condition. Or it could be that the RM might assume that subt=
>ype
>> checking has already been done, because the RM assume that the compiler a=
>nd
>> runtime has check that the bound is a scalar type.
>
>RM 4.1.2(7), 2nd sentence:
>
>"If the slice is not a null slice (a slice where the discrete_range is
>a null range), then a check is made that the bounds of the
>discrete_range belong to the index range of the array denoted by the
>prefix. Constraint_Error is raised if this check fails."
>
>Which bit of 'if' followed by 'then' are you having trouble with?
>
>Cheers
>-- Martin
>




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

* Re: unsigned type
  2009-07-16 13:54                     ` anon
@ 2009-07-16 14:41                       ` Martin
  2009-07-16 15:12                         ` Adam Beneschan
  0 siblings, 1 reply; 152+ messages in thread
From: Martin @ 2009-07-16 14:41 UTC (permalink / raw)


On Jul 16, 2:54 pm, a...@anon.org (anon) wrote:
> The Slice rule RM 4.1.2 ( 7 ) does not stop a vendor from checking the
> bounds type first. In GNAT, using the last program I posted you will see that
> GNAT, first checks the lower bound type then checks for a "null range". Which
> somewhat goes against the rule RM 4.1.2 ( 7 ).

You are confusing what a particular compiler does with the language
specification - GNAT by simply be buggy.

Cheers
-- Martin



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

* Re: unsigned type
  2009-07-16 14:41                       ` Martin
@ 2009-07-16 15:12                         ` Adam Beneschan
  0 siblings, 0 replies; 152+ messages in thread
From: Adam Beneschan @ 2009-07-16 15:12 UTC (permalink / raw)


On Jul 16, 7:41 am, Martin <martin.do...@btopenworld.com> wrote:
> On Jul 16, 2:54 pm, a...@anon.org (anon) wrote:
>
> > The Slice rule RM 4.1.2 ( 7 ) does not stop a vendor from checking the
> > bounds type first. In GNAT, using the last program I posted you will see that
> > GNAT, first checks the lower bound type then checks for a "null range". Which
> > somewhat goes against the rule RM 4.1.2 ( 7 ).
>
> You are confusing what a particular compiler does with the language
> specification - GNAT by simply be buggy.

Right.  I think that the issue here is that if the RM says something
like "Constraint_Error is raised if X and Y are true", then it doesn't
matter whether X or Y is checked first.  BUT: If you can somehow tell
from the results (not from examining the code or running it under a
debugger) that Y is being checked first, then the implementation is
wrong.  The last two sentences of 4.1.2(7) are, as far as I can tell,
equivalent to saying "Constraint_Error is raised if the slice is not a
null slice *and* the bounds of the discrete_range do not belong to the
index range of the array", so it's really irrelevant which of the two
conditions separated by "and" is checked first---as long as the result
is correct.  If an implementation checks the "bounds belong to range"
condition first, and raises Constraint_Error (or faults) if this check
fails even if the "null slice" condition is true, then of course the
implementation is wrong.

However, I looked over the example program in the "getting back to
null range" post and I couldn't see any evidence that GNAT is doing
anything wrong.  Part of the confusion there is that the program
seemed to have an error; as Christoph pointed out, the programmer was
using the value of an uninitialized variable in places where he
thought he was specifying a null range.

                                      -- Adam





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

* Learning Ada
@ 2010-07-24 14:21 Frederick Williams
  2010-07-24 16:21 ` Simon Wright
  2010-07-25 20:33 ` mockturtle
  0 siblings, 2 replies; 152+ messages in thread
From: Frederick Williams @ 2010-07-24 14:21 UTC (permalink / raw)


I wish to learn Ada(*) so I am looking for a free compiler to run on
Windows XP.  Any suggestions?

(* Do you really?  Yes, really.)
-- 
I can't go on, I'll go on.



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

* Re: Learning Ada
  2010-07-24 14:21 Frederick Williams
@ 2010-07-24 16:21 ` Simon Wright
  2010-07-25 20:33 ` mockturtle
  1 sibling, 0 replies; 152+ messages in thread
From: Simon Wright @ 2010-07-24 16:21 UTC (permalink / raw)


Frederick Williams <frederick.williams2@tesco.net> writes:

> I wish to learn Ada(*) so I am looking for a free compiler to run on
> Windows XP.  Any suggestions?

http://libre.adacore.com/

> (* Do you really?  Yes, really.)

Good for you!



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

* Re: Learning Ada
  2010-07-24 14:21 Frederick Williams
  2010-07-24 16:21 ` Simon Wright
@ 2010-07-25 20:33 ` mockturtle
  1 sibling, 0 replies; 152+ messages in thread
From: mockturtle @ 2010-07-25 20:33 UTC (permalink / raw)


On 24 Lug, 16:21, Frederick Williams <frederick.willia...@tesco.net>
wrote:
> I wish to learn Ada(*) so I am looking for a free compiler to run on
> Windows XP.  Any suggestions?
>
> (* Do you really?  Yes, really.)
> --
> I can't go on, I'll go on.

Welcome aboard!



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

* Learning Ada
@ 2020-09-15 10:36 Jack Davy
  2020-09-15 14:31 ` Anders Wirzenius
  2020-09-15 17:01 ` Simon Wright
  0 siblings, 2 replies; 152+ messages in thread
From: Jack Davy @ 2020-09-15 10:36 UTC (permalink / raw)


I've just started learning Ada and am using the book "Ada95: The Craft of Object Oriented Programming", by John English. I know there are plenty of other resources such as the one on Adacore, which covers Ada 2012, but I like the style and flow of this book. Anyway, I was wondering whether anyone in the group has the answers to the end of chapter exercises? The author has now retired and the link to them is dead.
Thanks in Advance!

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

* Re: Learning Ada
  2020-09-15 10:36 Learning Ada Jack Davy
@ 2020-09-15 14:31 ` Anders Wirzenius
  2020-09-15 15:07   ` Jack Davy
  2020-09-15 17:01 ` Simon Wright
  1 sibling, 1 reply; 152+ messages in thread
From: Anders Wirzenius @ 2020-09-15 14:31 UTC (permalink / raw)


Jack Davy <jules1.davy@gmail.com> writes:

> I've just started learning Ada and am using the book "Ada95: The Craft
> of Object Oriented Programming", by John English. I know there are
> plenty of other resources such as the one on Adacore, which covers Ada
> 2012, but I like the style and flow of this book. Anyway, I was
> wondering whether anyone in the group has the answers to the end of
> chapter exercises? The author has now retired and the link to them is
> dead.
> Thanks in Advance!

Maybe this helps:

http://archive.adaic.com/docs/craft/craft.html

-- 
Anders

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

* Re: Learning Ada
  2020-09-15 14:31 ` Anders Wirzenius
@ 2020-09-15 15:07   ` Jack Davy
  2020-09-15 15:54     ` Ludovic Brenta
  0 siblings, 1 reply; 152+ messages in thread
From: Jack Davy @ 2020-09-15 15:07 UTC (permalink / raw)


On Tuesday, September 15, 2020 at 3:32:00 PM UTC+1, Anders Wirzenius wrote:
> Jack Davy <jules...@gmail.com> writes: 
> 
> > I've just started learning Ada and am using the book "Ada95: The Craft 
> > of Object Oriented Programming", by John English. I know there are 
> > plenty of other resources such as the one on Adacore, which covers Ada 
> > 2012, but I like the style and flow of this book. Anyway, I was 
> > wondering whether anyone in the group has the answers to the end of 
> > chapter exercises? The author has now retired and the link to them is 
> > dead. 
> > Thanks in Advance!
> Maybe this helps: 
> 
> http://archive.adaic.com/docs/craft/craft.html 
> 
> -- 
> Anders
Thanks Anders, but I already found that link. The download has the code for the book, but no answers. I guess it's not important, I just thought it would be nice to see some sample solutions. 

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

* Re: Learning Ada
  2020-09-15 15:07   ` Jack Davy
@ 2020-09-15 15:54     ` Ludovic Brenta
  0 siblings, 0 replies; 152+ messages in thread
From: Ludovic Brenta @ 2020-09-15 15:54 UTC (permalink / raw)


Jack Davy <algojack@tutanota.com> writes:
> On Tuesday, September 15, 2020 at 3:32:00 PM UTC+1, Anders Wirzenius wrote:
>> Jack Davy <jules...@gmail.com> writes: 
>> 
>> > I've just started learning Ada and am using the book "Ada95: The Craft 
>> > of Object Oriented Programming", by John English. I know there are 
>> > plenty of other resources such as the one on Adacore, which covers Ada 
>> > 2012, but I like the style and flow of this book. Anyway, I was 
>> > wondering whether anyone in the group has the answers to the end of 
>> > chapter exercises? The author has now retired and the link to them is 
>> > dead. 
>> > Thanks in Advance!
>> Maybe this helps: 
>> 
>> http://archive.adaic.com/docs/craft/craft.html 
>> 
>> -- 
>> Anders
> Thanks Anders, but I already found that link. The download has the
> code for the book, but no answers. I guess it's not important, I just
> thought it would be nice to see some sample solutions.

I don't have an answer to your exact question but there is no shortage
of "sample solutions" in Ada on https://rosettacode.org/wiki/Category:Ada

HTH

PS. I still consider John English's book to be the best introduction to
Ada.

-- 
Ludovic Brenta.

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

* Re: Learning Ada
  2020-09-15 10:36 Learning Ada Jack Davy
  2020-09-15 14:31 ` Anders Wirzenius
@ 2020-09-15 17:01 ` Simon Wright
  2020-09-15 17:07   ` Simon Wright
  1 sibling, 1 reply; 152+ messages in thread
From: Simon Wright @ 2020-09-15 17:01 UTC (permalink / raw)


Jack Davy <jules1.davy@gmail.com> writes:

> I've just started learning Ada and am using the book "Ada95: The Craft
> of Object Oriented Programming", by John English. I know there are
> plenty of other resources such as the one on Adacore, which covers Ada
> 2012, but I like the style and flow of this book. Anyway, I was
> wondering whether anyone in the group has the answers to the end of
> chapter exercises? The author has now retired and the link to them is
> dead.

Try here: https://www.dropbox.com/s/8k4xxpj5a67s752/adacraft.tar.gz?dl=0

Nothing like being a pack rat! my hard disk copy is dated 2012-8-25, but
I don't know when I retrieved it, must ahve been several computers
ago. Internal dates up to 2001-07-27. Readme says examples tested with
GNAT 3.13p!

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

* Re: Learning Ada
  2020-09-15 17:01 ` Simon Wright
@ 2020-09-15 17:07   ` Simon Wright
  2020-09-15 19:03     ` Jack Davy
  0 siblings, 1 reply; 152+ messages in thread
From: Simon Wright @ 2020-09-15 17:07 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> Jack Davy <jules1.davy@gmail.com> writes:
>
>> I've just started learning Ada and am using the book "Ada95: The Craft
>> of Object Oriented Programming", by John English. I know there are
>> plenty of other resources such as the one on Adacore, which covers Ada
>> 2012, but I like the style and flow of this book. Anyway, I was
>> wondering whether anyone in the group has the answers to the end of
>> chapter exercises? The author has now retired and the link to them is
>> dead.
>
> Try here: https://www.dropbox.com/s/8k4xxpj5a67s752/adacraft.tar.gz?dl=0
>
> Nothing like being a pack rat! my hard disk copy is dated 2012-8-25, but
> I don't know when I retrieved it, must ahve been several computers
> ago. Internal dates up to 2001-07-27. Readme says examples tested with
> GNAT 3.13p!

Actually, they are at adaic.com:
http://archive.adaic.com/docs/craft/craft.html, see the third bullet point.

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

* Re: Learning Ada
  2020-09-15 17:07   ` Simon Wright
@ 2020-09-15 19:03     ` Jack Davy
  2020-09-15 19:28       ` Gautier write-only
                         ` (2 more replies)
  0 siblings, 3 replies; 152+ messages in thread
From: Jack Davy @ 2020-09-15 19:03 UTC (permalink / raw)


On Tuesday, September 15, 2020 at 6:07:16 PM UTC+1, Simon Wright wrote:
> Simon Wright <si...@pushface.org> writes: 
> 
> > Jack Davy <jules...@gmail.com> writes: 
> > 
> >> I've just started learning Ada and am using the book "Ada95: The Craft 
> >> of Object Oriented Programming", by John English. I know there are 
> >> plenty of other resources such as the one on Adacore, which covers Ada 
> >> 2012, but I like the style and flow of this book. Anyway, I was 
> >> wondering whether anyone in the group has the answers to the end of 
> >> chapter exercises? The author has now retired and the link to them is 
> >> dead. 
> > 
> > Try here: https://www.dropbox.com/s/8k4xxpj5a67s752/adacraft.tar.gz?dl=0 
> > 
> > Nothing like being a pack rat! my hard disk copy is dated 2012-8-25, but 
> > I don't know when I retrieved it, must ahve been several computers 
> > ago. Internal dates up to 2001-07-27. Readme says examples tested with 
> > GNAT 3.13p!
> Actually, they are at adaic.com: 
> http://archive.adaic.com/docs/craft/craft.html, see the third bullet point.

@ Ludovic, thanks for the link to rosettacode; very good source of examples. And good to hear that you rate the book highly. There don't seem to be many books on Ada, but there is a very recent one for beginners which I will probably get to fill in the gaps not covered by "The Craft".  https://www.apress.com/gp/book/9781484254271

@ Simon, thanks, but I already have that file. It contains all the code in the book but not the answers to the end of chapter questions. 

By the way, I see the author also wrote a GUI libary for Ada called JEWL, the files for which I have also downloaded. Pity it's for Windows only. I'm a Linux user although I do have Win XP on VirtualBox, but I don't believe the current GNAT compiler will run on it.

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

* Re: Learning Ada
  2020-09-15 19:03     ` Jack Davy
@ 2020-09-15 19:28       ` Gautier write-only
  2020-09-15 23:00       ` Jerry Petrey
  2020-09-16  1:23       ` Paul Rubin
  2 siblings, 0 replies; 152+ messages in thread
From: Gautier write-only @ 2020-09-15 19:28 UTC (permalink / raw)


Other sample sources:
Ada resources:
  - https://sourceforge.net/directory/language:ada/
  - https://www.adaic.org/ada-resources/

Small samples are embedded in the LEA editor (you can run it from Wine):
  https://sourceforge.net/projects/l-e-a/

From the menu: Action / Code sample. Choose your sample. Hit F9 for running.
Some samples stem from Rosetta Code BTW :-)

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

* Re: Learning Ada
  2020-09-15 19:03     ` Jack Davy
  2020-09-15 19:28       ` Gautier write-only
@ 2020-09-15 23:00       ` Jerry Petrey
  2020-09-16  1:23       ` Paul Rubin
  2 siblings, 0 replies; 152+ messages in thread
From: Jerry Petrey @ 2020-09-15 23:00 UTC (permalink / raw)


On 9/15/20 12:03, Jack Davy wrote:

> By the way, I see the author also wrote a GUI libary for Ada called JEWL, the files for which I have also downloaded. Pity it's for Windows only. I'm a Linux user although I do have Win XP on VirtualBox, but I don't believe the current GNAT compiler will run on it.
> 

Yes, his JEWL package is great. I used it many times to create Windows 
GUI apps and still use it some. I talked to John a number of times - he 
was very helpful. His book is one of the best!

Jerry

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

* Re: Learning Ada
  2020-09-15 19:03     ` Jack Davy
  2020-09-15 19:28       ` Gautier write-only
  2020-09-15 23:00       ` Jerry Petrey
@ 2020-09-16  1:23       ` Paul Rubin
  2020-09-16  7:13         ` Jack Davy
  2 siblings, 1 reply; 152+ messages in thread
From: Paul Rubin @ 2020-09-16  1:23 UTC (permalink / raw)


Jack Davy <algojack@tutanota.com> writes:
> seem to be many books on Ada, but there is a very recent one for
> beginners which I will probably get to fill in the gaps not covered by
> "The Craft".  https://www.apress.com/gp/book/9781484254271

I haven't examined that book directly but based on the preview and
blurb, it does seem to be beginner oriented, thus likely to have gaps of
its own.  If you're trying to fill gaps, you probably want something
more complete and advanced.

I semi-recently got another book that looks very good, though it's still
sitting around without my having read much of it: Analysable Real-Time
Systems: Programmed in Ada, by Andy Wellings and Alan Burns.  It is
basically an updated reprint of an older book by the same authors,
self-published in paperback, so it is a good value.

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

* Re: Learning Ada
  2020-09-16  1:23       ` Paul Rubin
@ 2020-09-16  7:13         ` Jack Davy
  2020-09-16  7:32           ` Jack Davy
                             ` (5 more replies)
  0 siblings, 6 replies; 152+ messages in thread
From: Jack Davy @ 2020-09-16  7:13 UTC (permalink / raw)


On Wednesday, September 16, 2020 at 2:23:21 AM UTC+1, Paul Rubin wrote:
> Jack Davy <algo...@tutanota.com> writes: 
> > seem to be many books on Ada, but there is a very recent one for 
> > beginners which I will probably get to fill in the gaps not covered by 
> > "The Craft". https://www.apress.com/gp/book/9781484254271
> I haven't examined that book directly but based on the preview and 
> blurb, it does seem to be beginner oriented, thus likely to have gaps of 
> its own. If you're trying to fill gaps, you probably want something 
> more complete and advanced. 
> 
> I semi-recently got another book that looks very good, though it's still 
> sitting around without my having read much of it: Analysable Real-Time 
> Systems: Programmed in Ada, by Andy Wellings and Alan Burns. It is 
> basically an updated reprint of an older book by the same authors, 
> self-published in paperback, so it is a good value.

@ Gautier, thanks for the links. When I get Windows 7 on VirtualBox I'll give the LEA editor a try, I'm not so keen on using Wine, it's a bit hit & miss. Also since I learned Vim a few years ago no other editors really do it for me, unless they have Vim bindings ;).

@ Paul, I was thinking that the beginner's Apress book would fill in the gaps regarding Ada 2012 specifically, which as I understand it has changed from previous versions mainly in regard to OOP; I'm assuming I won't need to unlearn anything if I learn the basics from an Ada 95 book. The real-time stuff would be over my head at this point I think, and not really something I had in mind when considering Ada, although I do have a background in electronics, and see that there is Ada compiler for AVR on adacore. 

The more I look at this language the more I wonder why it isn't more popular. Maybe people just don't like the pascalish syntax, but that never put me off because I learned Turbo Pascal at Uni (25 years ago) and more recently Free Pascal/Lazarus. Never was much of a fan of the curly bracket languages.

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

* Re: Learning Ada
  2020-09-16  7:13         ` Jack Davy
@ 2020-09-16  7:32           ` Jack Davy
  2020-09-16  9:13           ` Gautier write-only
                             ` (4 subsequent siblings)
  5 siblings, 0 replies; 152+ messages in thread
From: Jack Davy @ 2020-09-16  7:32 UTC (permalink / raw)


On Wednesday, September 16, 2020 at 8:13:23 AM UTC+1, Jack Davy wrote:
> On Wednesday, September 16, 2020 at 2:23:21 AM UTC+1, Paul Rubin wrote: 
> > Jack Davy <algo...@tutanota.com> writes: 
> > > seem to be many books on Ada, but there is a very recent one for 
> > > beginners which I will probably get to fill in the gaps not covered by 
> > > "The Craft". https://www.apress.com/gp/book/9781484254271 
> > I haven't examined that book directly but based on the preview and 
> > blurb, it does seem to be beginner oriented, thus likely to have gaps of 
> > its own. If you're trying to fill gaps, you probably want something 
> > more complete and advanced. 
> > 
> > I semi-recently got another book that looks very good, though it's still 
> > sitting around without my having read much of it: Analysable Real-Time 
> > Systems: Programmed in Ada, by Andy Wellings and Alan Burns. It is 
> > basically an updated reprint of an older book by the same authors, 
> > self-published in paperback, so it is a good value.
> @ Gautier, thanks for the links. When I get Windows 7 on VirtualBox I'll give the LEA editor a try, I'm not so keen on using Wine, it's a bit hit & miss. Also since I learned Vim a few years ago no other editors really do it for me, unless they have Vim bindings ;). 
> 
> @ Paul, I was thinking that the beginner's Apress book would fill in the gaps regarding Ada 2012 specifically, which as I understand it has changed from previous versions mainly in regard to OOP; I'm assuming I won't need to unlearn anything if I learn the basics from an Ada 95 book. The real-time stuff would be over my head at this point I think, and not really something I had in mind when considering Ada, although I do have a background in electronics, and see that there is Ada compiler for AVR on adacore. 
> 
> The more I look at this language the more I wonder why it isn't more popular. Maybe people just don't like the pascalish syntax, but that never put me off because I learned Turbo Pascal at Uni (25 years ago) and more recently Free Pascal/Lazarus. Never was much of a fan of the curly bracket languages.

I found an impressive list of 'Things to like about Ada' posted by a C/C++ career programmer on the AVR freaks forum (in reply #13)  : https://www.avrfreaks.net/forum/i-didnt-know-you-could-get-ada-avr

My main reason for wanting to learn Ada is the last on his list :

"Promotes a professional, anti-hacker mentality.
By being unforgiving the language promotes the valuable discipline of specifying and writing code more exactly, without the temptations of slipping into bit-twiddling or other programming habits that subvert (and often break) the data or code models. When proper programming discipline is not enforced by the language then it must be voluntary, and in those cases discipline can and inevitably will slip, but when the language enforces much of that discipline then there are no easy ways to avoid it, and the resulting code is higher in quality and faster to develop."

Maybe that's why Ada isn't more popular - being disciplined isn't easy, and hacking is more fun. But I've learned the hard way that it's actually much more satisfying when your programs are bug-free and work properly the first time you run them. Any language which enforces more thinking and less trial-and-error coding is a winner in my book.

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

* Re: Learning Ada
  2020-09-16  7:13         ` Jack Davy
  2020-09-16  7:32           ` Jack Davy
@ 2020-09-16  9:13           ` Gautier write-only
  2020-09-16 10:55           ` Ludovic Brenta
                             ` (3 subsequent siblings)
  5 siblings, 0 replies; 152+ messages in thread
From: Gautier write-only @ 2020-09-16  9:13 UTC (permalink / raw)


On Wednesday, September 16, 2020 at 9:13:23 AM UTC+2, Jack Davy wrote:
> @ Gautier, thanks for the links. When I get Windows 7 on VirtualBox I'll give the LEA editor a try, I'm not so keen on using Wine, it's a bit hit & miss. Also since I learned Vim a few years ago no other editors really do it for me, unless they have Vim bindings ;). 

No worries, you can access the same samples (and the same compiler) without LEA, built on your preferred operating system.
-> https://hacadacompiler.sourceforge.io/ (source code here: https://sourceforge.net/p/hacadacompiler/code/HEAD/tree/ , mirrored here: https://github.com/zertovitch/hac )
Mutatis mutandis, you get there the "tpc.exe" equivalent, whereas LEA is the "turbo.exe" :-)

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

* Re: Learning Ada
  2020-09-16  7:13         ` Jack Davy
  2020-09-16  7:32           ` Jack Davy
  2020-09-16  9:13           ` Gautier write-only
@ 2020-09-16 10:55           ` Ludovic Brenta
  2020-09-16 11:09             ` Dmitry A. Kazakov
  2020-09-16 15:01           ` Jeffrey R. Carter
                             ` (2 subsequent siblings)
  5 siblings, 1 reply; 152+ messages in thread
From: Ludovic Brenta @ 2020-09-16 10:55 UTC (permalink / raw)


Jack Davy <algojack@tutanota.com> writes:
> The more I look at this language the more I wonder why it isn't more
> popular. Maybe people just don't like the pascalish syntax, but that
> never put me off because I learned Turbo Pascal at Uni (25 years ago)
> and more recently Free Pascal/Lazarus. Never was much of a fan of the
> curly bracket languages.

I wasn't there when it happened but I read that early Ada 83 compilers
were buggy, slow and outrageously expensive because marketed only at one
captive customer, the US DoD.  (In their defence, Ada is a prticularly
difficult language to implement well, orders of magnitude more so than
Pascal or C).  The vendors never really tried to sell Ada development
tools outside the military, despite hype that Ada was the language of
the future.  At around the same time, C++ used the opposite strategy of
selling cheap compilers, with the additional advantage of backward
compatibility with C, so they won market share.  Turbo Pascal was a
contender back then but only on DOS and Windows, so it ultimately lost
to C++, possibly in no small part because of Borland's refusal to abide
by any portable standard.  And then Sun marketed Java aggressively with
a zero-cost compiler and promises of ultimate portability, and stole the
show.

The Ada landcsape changed dramatically when the first Free Sofwtare Ada
95 compiler, gnat, arrived, but the damage to the reputation of Ada was
very hard to overcome.  An entire generation of military and corporate
programmers, frustrated by the early compilers, became managers and
dismissed Ada out of hand for decades.  They and their prejudices have
started to retire in the past few years and I think this is one factor
in the current renaissance of Ada.

-- 
Ludovic Brenta.
The market thinker synergizes the cross-enterprise trends. 

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

* Re: Learning Ada
  2020-09-16 10:55           ` Ludovic Brenta
@ 2020-09-16 11:09             ` Dmitry A. Kazakov
  2020-10-02 18:43               ` gautier...@hotmail.com
  0 siblings, 1 reply; 152+ messages in thread
From: Dmitry A. Kazakov @ 2020-09-16 11:09 UTC (permalink / raw)


On 16/09/2020 12:55, Ludovic Brenta wrote:
> Jack Davy <algojack@tutanota.com> writes:
>> The more I look at this language the more I wonder why it isn't more
>> popular. Maybe people just don't like the pascalish syntax, but that
>> never put me off because I learned Turbo Pascal at Uni (25 years ago)
>> and more recently Free Pascal/Lazarus. Never was much of a fan of the
>> curly bracket languages.
> 
> I wasn't there when it happened but I read that early Ada 83 compilers
> were buggy, slow and outrageously expensive because marketed only at one
> captive customer, the US DoD.  (In their defence, Ada is a prticularly
> difficult language to implement well, orders of magnitude more so than
> Pascal or C).  The vendors never really tried to sell Ada development
> tools outside the military, despite hype that Ada was the language of
> the future.  At around the same time, C++ used the opposite strategy of
> selling cheap compilers, with the additional advantage of backward
> compatibility with C, so they won market share.  Turbo Pascal was a
> contender back then but only on DOS and Windows, so it ultimately lost
> to C++, possibly in no small part because of Borland's refusal to abide
> by any portable standard.  And then Sun marketed Java aggressively with
> a zero-cost compiler and promises of ultimate portability, and stole the
> show.
> 
> The Ada landcsape changed dramatically when the first Free Sofwtare Ada
> 95 compiler, gnat, arrived, but the damage to the reputation of Ada was
> very hard to overcome.  An entire generation of military and corporate
> programmers, frustrated by the early compilers, became managers and
> dismissed Ada out of hand for decades.  They and their prejudices have
> started to retire in the past few years and I think this is one factor
> in the current renaissance of Ada.

I mostly agree with your analysis, except the last part. The problem is 
that the culture of programming and overall education became so low that 
it is no more a race against C++. C++ itself is in defense and losing 
against languages and practices so overwhelmingly bad that even C looks 
as a shining beacon. Winter is coming.

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

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

* Re: Learning Ada
  2020-09-16  7:13         ` Jack Davy
                             ` (2 preceding siblings ...)
  2020-09-16 10:55           ` Ludovic Brenta
@ 2020-09-16 15:01           ` Jeffrey R. Carter
  2020-09-18  6:53             ` Mart van de Wege
  2020-09-16 21:29           ` Paul Rubin
  2020-10-06  4:06           ` andrew...@gmail.com
  5 siblings, 1 reply; 152+ messages in thread
From: Jeffrey R. Carter @ 2020-09-16 15:01 UTC (permalink / raw)


On 9/16/20 9:13 AM, Jack Davy wrote:
> 
> The more I look at this language the more I wonder why it isn't more popular.

Ada is a language for engineering software. Since 98% of developers are unable 
to do that, Ada will never be popular as long as such people are allowed to 
develop software.

-- 
Jeff Carter
"IMHO, Interfaces are worthless."
Randy Brukardt
117

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

* Re: Learning Ada
  2020-09-16  7:13         ` Jack Davy
                             ` (3 preceding siblings ...)
  2020-09-16 15:01           ` Jeffrey R. Carter
@ 2020-09-16 21:29           ` Paul Rubin
  2020-10-06  4:06           ` andrew...@gmail.com
  5 siblings, 0 replies; 152+ messages in thread
From: Paul Rubin @ 2020-09-16 21:29 UTC (permalink / raw)


Jack Davy <algojack@tutanota.com> writes:
> @ Paul, I was thinking that the beginner's Apress book would fill in
> the gaps regarding Ada 2012 specifically, which as I understand it has
> changed from previous versions mainly in regard to OOP

I think Ada 95 OOP is not really used very much, and the changes in Ada
2012 are things like contracts, and built-in SPARK syntax.  You could
also look at the online book "Ada Distilled" which is about Ada 95.  I
found it an ok way to get started, though I never really progressed
beyond that.

> I do have a background in electronics, and see that there is Ada
> compiler for AVR on adacore.

I don't know the current state of that, but some years ago it was rather
hard to use or parts were missing or whatever.  These days, the AVR is
in decline since it is so limited.  Everyone uses ARM or maybe soon
RISC-V processors even for tiny embedded stuff.

> The more I look at this language the more I wonder why it isn't more
> popular. Maybe people just don't like the pascalish syntax

Tooling, libraries, language verbosity, etc.  As pure language, though,
it is still mysterious to me what Rust offers that Ada doesn't.

Today, for most programming, "systems languages" including Ada, C, C++,
and Rust are all imho somewhat niche.  Unless you are dealing with
specialized problems (such as embedded or OS's), computers have almost
unbounded resources.  So it's easier to get your work done using
languages with automatic memory management, unbounded arithmetic, etc.

The main cost is consuming more machine resources and losing some timing
determinism, but most of the time you can live with both of those.  Ada
is best for more demanding applications which usually involve realtime
or high reliability constraints.

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

* Re: Learning Ada
  2020-09-16 15:01           ` Jeffrey R. Carter
@ 2020-09-18  6:53             ` Mart van de Wege
  2020-09-18 10:00               ` Jeffrey R. Carter
  0 siblings, 1 reply; 152+ messages in thread
From: Mart van de Wege @ 2020-09-18  6:53 UTC (permalink / raw)


"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:

> On 9/16/20 9:13 AM, Jack Davy wrote:
>>
>> The more I look at this language the more I wonder why it isn't more popular.
>
> Ada is a language for engineering software. Since 98% of developers
> are unable to do that, Ada will never be popular as long as such
> people are allowed to develop software.

I use it for hobby stuff, for quick solutions (like generating RPG
characters). Does not feel like engineering to me.

But what I do like is the elegance of the language, and the ability to
describe my problem domain using distinct types.

The 'verbosity' does not bother me. I'm a fluent touch typist, Using the
shift key to type braces slows me more than typing out statements to
delineate blocks.

The only real nit I have with Ada is that it does not have closures.

Mart

-- 
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.

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

* Re: Learning Ada
  2020-09-18  6:53             ` Mart van de Wege
@ 2020-09-18 10:00               ` Jeffrey R. Carter
  0 siblings, 0 replies; 152+ messages in thread
From: Jeffrey R. Carter @ 2020-09-18 10:00 UTC (permalink / raw)


On 9/18/20 8:53 AM, Mart van de Wege wrote:
> 
> I use it for hobby stuff, for quick solutions (like generating RPG
> characters). Does not feel like engineering to me.

I do similar things, too, but I always have a design in mind, and usually start 
with pkg, task, & PO specs and subprogram declarations, so I suspect that after 
doing this for so long I can engineer simple problems in my head. Presumably 
others with similar experience or who are better than I do the same.

-- 
Jeff Carter
"Crucifixion's a doddle."
Monty Python's Life of Brian
82

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

* Re: Learning Ada
  2020-09-16 11:09             ` Dmitry A. Kazakov
@ 2020-10-02 18:43               ` gautier...@hotmail.com
  2020-10-03  6:43                 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 152+ messages in thread
From: gautier...@hotmail.com @ 2020-10-02 18:43 UTC (permalink / raw)


On Wednesday, September 16, 2020 at 1:09:57 PM UTC+2, Dmitry A. Kazakov wrote:

> I mostly agree with your analysis, except the last part. The problem is 
> that the culture of programming and overall education became so low that 
> it is no more a race against C++. C++ itself is in defense and losing 
> against languages and practices so overwhelmingly bad that even C looks 
> as a shining beacon. Winter is coming. 

20-30 years ago the pointy haired bosses would warmly recommend a buzzword called C++ (or something spelled "tchavasiblosblos" in some places) for Aïti projects, but now they all want a digital transformation strategy with blockchain and machine learning. I'm not sure if the level is really lower (we tend to make the past nicer in our minds). But clearly the notion of programming language was lost on the way :-) ...

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

* Re: Learning Ada
  2020-10-02 18:43               ` gautier...@hotmail.com
@ 2020-10-03  6:43                 ` Dmitry A. Kazakov
  2020-10-05 18:36                   ` Shark8
  2020-10-17 19:28                   ` antispam
  0 siblings, 2 replies; 152+ messages in thread
From: Dmitry A. Kazakov @ 2020-10-03  6:43 UTC (permalink / raw)


On 02/10/2020 20:43, gautier...@hotmail.com wrote:
> On Wednesday, September 16, 2020 at 1:09:57 PM UTC+2, Dmitry A. Kazakov wrote:
> 
>> I mostly agree with your analysis, except the last part. The problem is
>> that the culture of programming and overall education became so low that
>> it is no more a race against C++. C++ itself is in defense and losing
>> against languages and practices so overwhelmingly bad that even C looks
>> as a shining beacon. Winter is coming.
> 
> 20-30 years ago the pointy haired bosses would warmly recommend a buzzword called C++ (or something spelled "tchavasiblosblos" in some places) for Aïti projects, but now they all want a digital transformation strategy with blockchain and machine learning. I'm not sure if the level is really lower (we tend to make the past nicer in our minds). But clearly the notion of programming language was lost on the way :-) ...

Well, the method of ML used in these days goes back to an idea from 
50's. It was promptly discarded then as too weak to solve elementary 
classification problems. The AI of late 80's was far more diversified, 
advanced and powerful than this mockery, yet it died peacefully, because 
of limitations it had. I don't even know what to think about all this.

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

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

* Re: Learning Ada
  2020-10-03  6:43                 ` Dmitry A. Kazakov
@ 2020-10-05 18:36                   ` Shark8
  2020-10-17 19:28                   ` antispam
  1 sibling, 0 replies; 152+ messages in thread
From: Shark8 @ 2020-10-05 18:36 UTC (permalink / raw)


On Saturday, October 3, 2020 at 12:43:38 AM UTC-6, Dmitry A. Kazakov wrote:
> I don't even know what to think about all this.

"Marketing Hype."

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

* Re: Learning Ada
  2020-09-16  7:13         ` Jack Davy
                             ` (4 preceding siblings ...)
  2020-09-16 21:29           ` Paul Rubin
@ 2020-10-06  4:06           ` andrew...@gmail.com
  2020-10-06  7:32             ` Jack Davy
  5 siblings, 1 reply; 152+ messages in thread
From: andrew...@gmail.com @ 2020-10-06  4:06 UTC (permalink / raw)


On Wednesday, September 16, 2020 at 3:13:23 AM UTC-4, Jack Davy wrote:
> On Wednesday, September 16, 2020 at 2:23:21 AM UTC+1, Paul Rubin wrote: 
> > Jack Davy <algo...@tutanota.com> writes: 
> > > seem to be many books on Ada, but there is a very recent one for 
> > > beginners which I will probably get to fill in the gaps not covered by 
> > > "The Craft". https://www.apress.com/gp/book/9781484254271 
> > I haven't examined that book directly but based on the preview and 
> > blurb, it does seem to be beginner oriented, thus likely to have gaps of 
> > its own. If you're trying to fill gaps, you probably want something 
> > more complete and advanced. 
> > 
> > I semi-recently got another book that looks very good, though it's still 
> > sitting around without my having read much of it: Analysable Real-Time 
> > Systems: Programmed in Ada, by Andy Wellings and Alan Burns. It is 
> > basically an updated reprint of an older book by the same authors, 
> > self-published in paperback, so it is a good value.
> @ Gautier, thanks for the links. When I get Windows 7 on VirtualBox I'll give the LEA editor a try, I'm not so keen on using Wine, it's a bit hit & miss. Also since I learned Vim a few years ago no other editors really do it for me, unless they have Vim bindings ;). 
> 
> @ Paul, I was thinking that the beginner's Apress book would fill in the gaps regarding Ada 2012 specifically, which as I understand it has changed from previous versions mainly in regard to OOP; I'm assuming I won't need to unlearn anything if I learn the basics from an Ada 95 book. The real-time stuff would be over my head at this point I think, and not really something I had in mind when considering Ada, although I do have a background in electronics, and see that there is Ada compiler for AVR on adacore. 
> 
> The more I look at this language the more I wonder why it isn't more popular. Maybe people just don't like the pascalish syntax, but that never put me off because I learned Turbo Pascal at Uni (25 years ago) and more recently Free Pascal/Lazarus. Never was much of a fan of the curly bracket languages.

Beginning Ada Programming is meant to be a gentle and guided introduction to Ada.  It does cover Ada 2012 topics and all of the code was compiled on an Ada 2012 compiler to make sure that it worked.

My goal was never to compete with the other more advanced books on Ada, but to provide an easier way to get learn this wonderful language and become more comfortable with writing code in it.

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

* Re: Learning Ada
  2020-10-06  4:06           ` andrew...@gmail.com
@ 2020-10-06  7:32             ` Jack Davy
  2020-10-17 23:02               ` mgr
  0 siblings, 1 reply; 152+ messages in thread
From: Jack Davy @ 2020-10-06  7:32 UTC (permalink / raw)


On Tuesday, October 6, 2020 at 5:06:20 AM UTC+1, andrew...@gmail.com wrote:
> On Wednesday, September 16, 2020 at 3:13:23 AM UTC-4, Jack Davy wrote: 
> > On Wednesday, September 16, 2020 at 2:23:21 AM UTC+1, Paul Rubin wrote: 
> > > Jack Davy <algo...@tutanota.com> writes: 
> > > > seem to be many books on Ada, but there is a very recent one for 
> > > > beginners which I will probably get to fill in the gaps not covered by 
> > > > "The Craft". https://www.apress.com/gp/book/9781484254271 
> > > I haven't examined that book directly but based on the preview and 
> > > blurb, it does seem to be beginner oriented, thus likely to have gaps of 
> > > its own. If you're trying to fill gaps, you probably want something 
> > > more complete and advanced. 
> > > 
> > > I semi-recently got another book that looks very good, though it's still 
> > > sitting around without my having read much of it: Analysable Real-Time 
> > > Systems: Programmed in Ada, by Andy Wellings and Alan Burns. It is 
> > > basically an updated reprint of an older book by the same authors, 
> > > self-published in paperback, so it is a good value. 
> > @ Gautier, thanks for the links. When I get Windows 7 on VirtualBox I'll give the LEA editor a try, I'm not so keen on using Wine, it's a bit hit & miss. Also since I learned Vim a few years ago no other editors really do it for me, unless they have Vim bindings ;). 
> > 
> > @ Paul, I was thinking that the beginner's Apress book would fill in the gaps regarding Ada 2012 specifically, which as I understand it has changed from previous versions mainly in regard to OOP; I'm assuming I won't need to unlearn anything if I learn the basics from an Ada 95 book. The real-time stuff would be over my head at this point I think, and not really something I had in mind when considering Ada, although I do have a background in electronics, and see that there is Ada compiler for AVR on adacore. 
> > 
> > The more I look at this language the more I wonder why it isn't more popular. Maybe people just don't like the pascalish syntax, but that never put me off because I learned Turbo Pascal at Uni (25 years ago) and more recently Free Pascal/Lazarus. Never was much of a fan of the curly bracket languages.
> Beginning Ada Programming is meant to be a gentle and guided introduction to Ada. It does cover Ada 2012 topics and all of the code was compiled on an Ada 2012 compiler to make sure that it worked. 
> 
> My goal was never to compete with the other more advanced books on Ada, but to provide an easier way to get learn this wonderful language and become more comfortable with writing code in it.

I  intend to purchase your book but at the moment I'm working through this one :
https://www2.seas.gwu.edu/~mfeldman/cs1book/
It has many example programs and is clearly written, although it only covers up to Ada 95. I'm not new to programming so I'm getting through it pretty quickly. I've download John English's JEWL library and have successfully compiled a few of the example programs using Wine on Linux. It seems very easy to use compared to most GUI libraries. A Linux port of it would be nice but I wouldn't know where to start with that.

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

* Re: Learning Ada
  2020-10-03  6:43                 ` Dmitry A. Kazakov
  2020-10-05 18:36                   ` Shark8
@ 2020-10-17 19:28                   ` antispam
  2020-10-17 22:47                     ` Randy Brukardt
  1 sibling, 1 reply; 152+ messages in thread
From: antispam @ 2020-10-17 19:28 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
> On 02/10/2020 20:43, gautier...@hotmail.com wrote:
> > On Wednesday, September 16, 2020 at 1:09:57 PM UTC+2, Dmitry A. Kazakov wrote:
> > 
> >> I mostly agree with your analysis, except the last part. The problem is
> >> that the culture of programming and overall education became so low that
> >> it is no more a race against C++. C++ itself is in defense and losing
> >> against languages and practices so overwhelmingly bad that even C looks
> >> as a shining beacon. Winter is coming.
> > 
> > 20-30 years ago the pointy haired bosses would warmly recommend a buzzword called C++ (or something spelled "tchavasiblosblos" in some places) for A?ti projects, but now they all want a digital transformation strategy with blockchain and machine learning. I'm not sure if the level is really lower (we tend to make the past nicer in our minds). But clearly the notion of programming language was lost on the way :-) ...
> 
> Well, the method of ML used in these days goes back to an idea from 
> 50's. It was promptly discarded then as too weak to solve elementary 
> classification problems. The AI of late 80's was far more diversified, 
> advanced and powerful than this mockery, yet it died peacefully, because 
> of limitations it had. I don't even know what to think about all this.

Hmm, I would say that progress from perceptron in 50 to current ANN
is bigger than progress from FORTRAN to Ada.  Would you accept
critique of Ada based on experience with FORTRAN?  Anyway,
ML researches tried various methods and currently ANN give
best results.  Using methods from 80's it would be hard or
impossible to get results obtained by modern methods.

I would very much prefer more principled apprach than ANN,
but arguing against reality is not productive...

-- 
                              Waldek Hebisch

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

* Re: Learning Ada
  2020-10-17 19:28                   ` antispam
@ 2020-10-17 22:47                     ` Randy Brukardt
  2020-10-18  6:45                       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 152+ messages in thread
From: Randy Brukardt @ 2020-10-17 22:47 UTC (permalink / raw)


<antispam@math.uni.wroc.pl> wrote in message 
news:rmfglq$dlh$1@z-news.wcss.wroc.pl...
> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>> On 02/10/2020 20:43, gautier...@hotmail.com wrote:
>> > On Wednesday, September 16, 2020 at 1:09:57 PM UTC+2, Dmitry A. Kazakov 
>> > wrote:
>> >
>> >> I mostly agree with your analysis, except the last part. The problem 
>> >> is
>> >> that the culture of programming and overall education became so low 
>> >> that
>> >> it is no more a race against C++. C++ itself is in defense and losing
>> >> against languages and practices so overwhelmingly bad that even C 
>> >> looks
>> >> as a shining beacon. Winter is coming.
>> >
>> > 20-30 years ago the pointy haired bosses would warmly recommend a 
>> > buzzword called C++ (or something spelled "tchavasiblosblos" in some 
>> > places) for A?ti projects, but now they all want a digital 
>> > transformation strategy with blockchain and machine learning. I'm not 
>> > sure if the level is really lower (we tend to make the past nicer in 
>> > our minds). But clearly the notion of programming language was lost on 
>> > the way :-) ...
>>
>> Well, the method of ML used in these days goes back to an idea from
>> 50's. It was promptly discarded then as too weak to solve elementary
>> classification problems. The AI of late 80's was far more diversified,
>> advanced and powerful than this mockery, yet it died peacefully, because
>> of limitations it had. I don't even know what to think about all this.
>
> Hmm, I would say that progress from perceptron in 50 to current ANN
> is bigger than progress from FORTRAN to Ada.  Would you accept
> critique of Ada based on experience with FORTRAN?  Anyway,
> ML researches tried various methods and currently ANN give
> best results.  Using methods from 80's it would be hard or
> impossible to get results obtained by modern methods.
>
> I would very much prefer more principled apprach than ANN,
> but arguing against reality is not productive...

The reality is that (non-artificial) intelligence seems to no longer exist, 
at least where people have power. One can either try to alter that reality, 
or accept impending doom. Not sure where I stand anymore on this.

                                Randy. 


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

* Re: Learning Ada
  2020-10-06  7:32             ` Jack Davy
@ 2020-10-17 23:02               ` mgr
  2020-10-22 10:32                 ` Jeffrey R. Carter
  0 siblings, 1 reply; 152+ messages in thread
From: mgr @ 2020-10-17 23:02 UTC (permalink / raw)


Am 6/10/20 um 9:32 schrieb Jack Davy:
> I  intend to purchase your book but at the moment I'm working through this one :
> https://www2.seas.gwu.edu/~mfeldman/cs1book/
> It has many example programs and is clearly written, although it only covers up to Ada 95. I'm not new to programming so I'm getting through it pretty quickly. I've download John English's JEWL library and have successfully compiled a few of the example programs using Wine on Linux. It seems very easy to use compared to most GUI libraries. A Linux port of it would be nice but I wouldn't know where to start with that.
> 

I know about this port of JEWL to GtkAda, but might be old and probably 
would require an old version of Gtk. I haven't tried it.

https://deim.urv.cat/~sergio.gomez/ada/simpleguis.php

Project documentation (in Spanish):

https://docplayer.es/44482143-Mejora-y-migracion-a-gtkada-de-la-libreria-jewl.html

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

* Re: Learning Ada
  2020-10-17 22:47                     ` Randy Brukardt
@ 2020-10-18  6:45                       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 152+ messages in thread
From: Dmitry A. Kazakov @ 2020-10-18  6:45 UTC (permalink / raw)


On 18/10/2020 00:47, Randy Brukardt wrote:

> The reality is that (non-artificial) intelligence seems to no longer exist,
> at least where people have power. One can either try to alter that reality,
> or accept impending doom. Not sure where I stand anymore on this.

Huh, it is called democracy, egalitarianism, rule of the mob, each vote 
counts etc. The aggregated intelligence of a crowd of people is below 
the intelligence of its dumbest member. Neither deep hierarchies nor 
flat organizations work well. Intelligence is there you need to pick it 
up. E.g. perceptron does not work, but you could transform the inputs to 
make it working. Transforming inputs, that is the idea, social networks, 
media and search engines are working hard on altering the reality, do 
not worry... (:-))

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

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

* Re: Learning Ada
  2020-10-17 23:02               ` mgr
@ 2020-10-22 10:32                 ` Jeffrey R. Carter
  0 siblings, 0 replies; 152+ messages in thread
From: Jeffrey R. Carter @ 2020-10-22 10:32 UTC (permalink / raw)


On 10/18/20 1:02 AM, mgr wrote:
> Am 6/10/20 um 9:32 schrieb Jack Davy:
>> I  intend to purchase your book but at the moment I'm working through this one :
>> https://www2.seas.gwu.edu/~mfeldman/cs1book/
>> It has many example programs and is clearly written, although it only covers 
>> up to Ada 95. I'm not new to programming so I'm getting through it pretty 
>> quickly. I've download John English's JEWL library and have successfully 
>> compiled a few of the example programs using Wine on Linux. It seems very easy 
>> to use compared to most GUI libraries. A Linux port of it would be nice but I 
>> wouldn't know where to start with that.
>>
> 
> I know about this port of JEWL to GtkAda, but might be old and probably would 
> require an old version of Gtk. I haven't tried it.
> 
> https://deim.urv.cat/~sergio.gomez/ada/simpleguis.php
> 
> Project documentation (in Spanish):
> 
> https://docplayer.es/44482143-Mejora-y-migracion-a-gtkada-de-la-libreria-jewl.html

There is a JEWL-inspired library called Win_IO:

https://www.ctr.unican.es/Win_IO/

-- 
Jeff Carter
"If a sperm is wasted, God gets quite irate."
Monty Python's the Meaning of Life
56

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

end of thread, other threads:[~2020-10-22 10:32 UTC | newest]

Thread overview: 152+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-28 15:36 unsigned type Rob Solomon
2009-06-28 15:45 ` Florian Weimer
2009-06-28 15:48 ` Albrecht Käfer
2009-06-28 17:56 ` anon
2009-06-28 19:17   ` Ludovic Brenta
2009-06-28 23:08     ` anon
2009-06-29  0:19       ` tmoran
2009-06-29  8:00         ` anon
2009-06-29  9:56           ` Jean-Pierre Rosen
2009-06-29 10:21             ` Ludovic Brenta
2009-06-29 11:23               ` sjw
2009-06-29 12:07                 ` Jean-Pierre Rosen
2009-06-29 20:06                 ` anon
2009-06-29 19:31               ` anon
2009-06-29 21:49                 ` Georg Bauhaus
     [not found]                 ` <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>
2009-06-30 11:29                   ` anon
2009-06-30 12:19                     ` Ludovic Brenta
2009-06-29 20:19             ` anon
2009-06-29 20:41               ` Ludovic Brenta
2009-06-29 22:15               ` Georg Bauhaus
2009-06-29 23:08               ` Adam Beneschan
2009-06-29 23:11               ` Adam Beneschan
2009-06-30 12:39               ` Martin
2009-06-29 10:25           ` Georg Bauhaus
2009-06-29 20:02             ` anon
2009-06-29 22:08               ` Georg Bauhaus
2009-06-30 23:01                 ` Randy Brukardt
2009-06-30 13:46               ` Jean-Pierre Rosen
2009-06-30 15:22                 ` Adam Beneschan
2009-06-30 15:59                   ` Albrecht Käfer
2009-06-30 16:59                     ` Adam Beneschan
2009-06-30 17:44                       ` Albrecht Käfer
2009-06-30 18:13                         ` Robert A Duff
2009-06-30 18:16                           ` Albrecht Käfer
2009-06-30 23:48                       ` anon
2009-07-01  1:39                         ` Adam Beneschan
2009-07-02 19:04                           ` anon
2009-07-02 19:49                           ` anon
2009-07-02 21:37                             ` Adam Beneschan
2009-07-03  1:42                             ` anon
2009-07-03  2:10                               ` Adam Beneschan
2009-07-03  7:07                             ` Jean-Pierre Rosen
2009-07-03 20:53                               ` anon
2009-07-03 21:24                                 ` Georg Bauhaus
2009-07-04  9:09                                   ` anon
2009-07-04 13:43                                     ` Georg Bauhaus
2009-07-06  9:04                                     ` AdaMagica
2009-07-03 21:46                                 ` Adam Beneschan
2009-07-04 12:39                                   ` Martin
2009-07-01  8:09                   ` Jean-Pierre Rosen
2009-07-01 15:08                     ` Albrecht Käfer
2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
2009-07-11 17:18             ` sjw
2009-07-11 18:15               ` Hibou57 (Yannick Duchêne)
2009-07-11 20:20             ` anon
2009-07-12 17:57               ` Samuel Tardieu
2009-07-12 18:24                 ` AdaMagica
2009-07-13 22:03                 ` anon
2009-07-14  7:58                   ` Martin
2009-07-16 13:54                     ` anon
2009-07-16 14:41                       ` Martin
2009-07-16 15:12                         ` Adam Beneschan
2009-07-11 14:43           ` Hibou57 (Yannick Duchêne)
2009-07-11 15:22             ` Albrecht Käfer
2009-06-29  8:42       ` Martin
2009-06-29  8:54         ` Dmitry A. Kazakov
2009-06-29 10:10           ` Martin
2009-06-29 12:34             ` Dmitry A. Kazakov
2009-06-29 19:26             ` anon
2009-06-29 23:02               ` Martin
2009-06-29 19:47           ` anon
2009-06-30  8:31             ` Ludovic Brenta
2009-06-28 19:54   ` tmoran
2009-06-28 22:34     ` Gary Scott
2009-06-28 23:15       ` John B. Matthews
2009-06-28 23:21       ` anon
2009-06-29  7:18       ` Dmitry A. Kazakov
2009-06-29  9:52         ` Georg Bauhaus
2009-06-29 12:43           ` Dmitry A. Kazakov
2009-06-29 13:36     ` Rob Solomon
2009-06-29 14:03       ` Robert A Duff
2009-06-29 14:13       ` Georg Bauhaus
2009-06-29 14:18       ` Ludovic Brenta
2009-06-29 15:40         ` Robert A Duff
2009-07-03  1:41         ` Rob Solomon
2009-07-03  7:12           ` Learning Ada (Was: unsigned type) Jacob Sparre Andersen
2009-07-03  8:38             ` Learning Ada Peter Hermann
2009-07-03  9:44               ` Georg Bauhaus
2009-07-03 22:20             ` Learning Ada (Was: unsigned type) anon
2009-07-04 14:53               ` Georg Bauhaus
2009-07-05 23:21                 ` anon
2009-07-06  0:05                   ` Ludovic Brenta
2009-07-06  0:19                   ` Learning Ada Albrecht Käfer
2009-07-06  2:50                     ` anon
2009-07-06  6:18                       ` AdaMagica
2009-07-06  7:47                         ` Jean-Pierre Rosen
2009-07-06 20:21                         ` anon
2009-07-06 21:08                           ` Georg Bauhaus
2009-07-06 22:43                           ` Frank J. Lhota
2009-07-09 22:28                             ` anon
2009-07-10  6:23                               ` AdaMagica
2009-07-06 10:53                   ` Learning Ada (Was: unsigned type) Georg Bauhaus
2009-07-06 19:34                     ` anon
2009-07-06 20:29                       ` Learning Ada Albrecht Käfer
2009-07-06 21:04                       ` Learning Ada (Was: unsigned type) Georg Bauhaus
2009-07-07 19:25                       ` sjw
2009-07-06 23:15                   ` Randy Brukardt
2009-07-07 15:29                     ` Adam Beneschan
2009-07-09  0:15                       ` Randy Brukardt
2009-07-09 15:26                         ` Adam Beneschan
2009-06-29 15:37       ` unsigned type Adam Beneschan
2009-07-06 20:20       ` Dave
2009-06-29 16:51 ` Martin Krischik
  -- strict thread matches above, loose matches on Subject: below --
2020-09-15 10:36 Learning Ada Jack Davy
2020-09-15 14:31 ` Anders Wirzenius
2020-09-15 15:07   ` Jack Davy
2020-09-15 15:54     ` Ludovic Brenta
2020-09-15 17:01 ` Simon Wright
2020-09-15 17:07   ` Simon Wright
2020-09-15 19:03     ` Jack Davy
2020-09-15 19:28       ` Gautier write-only
2020-09-15 23:00       ` Jerry Petrey
2020-09-16  1:23       ` Paul Rubin
2020-09-16  7:13         ` Jack Davy
2020-09-16  7:32           ` Jack Davy
2020-09-16  9:13           ` Gautier write-only
2020-09-16 10:55           ` Ludovic Brenta
2020-09-16 11:09             ` Dmitry A. Kazakov
2020-10-02 18:43               ` gautier...@hotmail.com
2020-10-03  6:43                 ` Dmitry A. Kazakov
2020-10-05 18:36                   ` Shark8
2020-10-17 19:28                   ` antispam
2020-10-17 22:47                     ` Randy Brukardt
2020-10-18  6:45                       ` Dmitry A. Kazakov
2020-09-16 15:01           ` Jeffrey R. Carter
2020-09-18  6:53             ` Mart van de Wege
2020-09-18 10:00               ` Jeffrey R. Carter
2020-09-16 21:29           ` Paul Rubin
2020-10-06  4:06           ` andrew...@gmail.com
2020-10-06  7:32             ` Jack Davy
2020-10-17 23:02               ` mgr
2020-10-22 10:32                 ` Jeffrey R. Carter
2010-07-24 14:21 Frederick Williams
2010-07-24 16:21 ` Simon Wright
2010-07-25 20:33 ` mockturtle
     [not found] <36841f24.293012@news.ptd.net>
1998-12-25  0:00 ` learning ada LeakyStain
1998-12-26  0:00   ` David Botton
1989-06-15  1:48 Learning ADA Krishan M Nainani
1989-06-15 14:19 ` Rosa Weber
1985-09-06 15:10 Learning Ada Marty Sasaki
     [not found] <332@harvard.UUCP>
1985-09-04 16:07 ` richw
1985-09-03  2:46 Marty Sasaki

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