comp.lang.ada
 help / color / mirror / Atom feed
From: Jim Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: Concatenation and Characters
Date: Tue, 22 Oct 2002 03:46:28 GMT
Date: 2002-10-22T03:46:28+00:00	[thread overview]
Message-ID: <3DB4C9C4.1070003@worldnet.att.net> (raw)
In-Reply-To: 3DB466CB.7CE0BC59@mmm.com

Programmer Dude wrote:


> I guess I'm wondering what behavior the language requires.  If it is
> required that uninitialized variables never be evaluated, I can see
> an implementation choosing not to attempt to diagnose this at compile
> time and using another mechanism to detect it at run-time (such as
> special values or descriptor bits or whatever).
>



One of the reasons default initialization is difficult for numerics
in Ada is because Ada allows you to define your own numeric types.
This means that the language cannot assume any particular value is
always a correct value for any numeric type.

You can write your code to get around this using the scalar attributes
'First or 'Last as values for explicit initialization. When using
compound types such as arrays or record types you can use explicit
initialization syntax. Record definitions also allow you to specify
your own initial value for each field. In fact, these initial values
go a long way to providing the capabilities of default constructors in
other languages.

Note that the 'Valid attribute can be checked before accessing any
variable. This attribute returns TRUE when the variable contains a
valid value and FALSE when the variable contains an invalid value.

Following is an excerpt from the Ada Language Reference Manual.

13.9.1 Data Validity

Certain actions that can potentially lead to erroneous execution are not 
directly erroneous, but instead can cause objects to become abnormal. Subsequent 
uses of abnormal objects can be erroneous.

A scalar object can have an invalid representation, which means that the 
object's representation does not represent any value of the object's subtype. 
The primary cause of invalid representations is uninitialized variables.

Abnormal objects and invalid representations are explained in this subclause.

Dynamic Semantics

When an object is first created, and any explicit or default initializations 
have been performed, the object and all of its parts are in the normal state. 
Subsequent operations generally leave them normal. However, an object or part of 
an object can become abnormal in the following ways:

� An assignment to the object is disrupted due to an abort (see 9.8) or due to 
the failure of a language-defined check (see 11.6).

� The object is not scalar, and is passed to an in out or out parameter of an 
imported procedure or language-defined input procedure, if after return from the 
procedure the representation of the parameter does not represent a value of the 
parameter's subtype.

Whether or not an object actually becomes abnormal in these cases is not 
specified. An abnormal object becomes normal again upon successful completion of 
an assignment to the object as a whole.

Erroneous Execution

It is erroneous to evaluate a primary that is a name denoting an abnormal 
object, or to evaluate a prefix that denotes an abnormal object.

Bounded (Run-Time) Errors

If the representation of a scalar object does not represent a value of the 
object's subtype (perhaps because the object was not initialized), the object is 
said to have an invalid representation. It is a bounded error to evaluate the 
value of such an object. If the error is detected, either Constraint_Error or 
Program_Error is raised. Otherwise, execution continues using the invalid 
representation. The rules of the language outside this subclause assume that all 
objects have valid representations. The semantics of operations on invalid 
representations are as follows:

� If the representation of the object represents a value of the object's type, 
the value of the type is used.

� If the representation of the object does not represent a value of the object's 
type, the semantics of operations on such representations is 
implementation-defined, but does not by itself lead to erroneous or 
unpredictable execution, or to other objects becoming abnormal.

Erroneous Execution

A call to an imported function or an instance of Unchecked_Conversion is 
erroneous if the result is scalar, and the result object has an invalid 
representation.

The dereference of an access value is erroneous if it does not designate an 
object of an appropriate type or a subprogram with an appropriate profile, if it 
designates a nonexistent object, or if it is an access-to-variable value that 
designates a constant object. Such an access value can exist, for example, 
because of Unchecked_Deallocation, Unchecked_Access, or Unchecked_Conversion.

NOTES

18 Objects can become abnormal due to other kinds of actions that directly 
update the object's representation; such actions are generally considered 
directly erroneous, however.




Jim Rogers




  parent reply	other threads:[~2002-10-22  3:46 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-10 14:50 Concatenation and Characters Justin Birtwell
2002-10-10 14:55 ` Preben Randhol
2002-10-10 15:04   ` Justin Birtwell
2002-10-10 15:22     ` Preben Randhol
2002-10-10 15:30       ` Justin Birtwell
2002-10-10 16:05         ` Georg Bauhaus
2002-10-10 16:07         ` Preben Randhol
2002-10-10 17:45         ` Robert A Duff
2002-10-10 15:32       ` Justin Birtwell
2002-10-10 15:36         ` Preben Randhol
2002-10-10 16:44         ` Mark Biggar
2002-10-10 17:45           ` Stephen Leake
2002-10-10 21:53             ` Mark Biggar
2002-10-18 17:03           ` Programmer Dude
2002-10-18 18:13             ` Preben Randhol
2002-10-18 18:36             ` Wes Groleau
2002-10-21 15:16               ` Georg Bauhaus
2002-10-18 21:33             ` Mark Biggar
2002-10-20  2:01               ` Dmitry A.Kazakov
2002-10-21 14:13                 ` Wes Groleau
2002-10-21 15:22                   ` Dmitry A. Kazakov
2002-10-21 19:38                     ` Georg Bauhaus
2002-10-22 22:15                       ` Dmitry A.Kazakov
2002-10-22 12:05                         ` Georg Bauhaus
2002-10-22 12:19                           ` Lutz Donnerhacke
2002-10-22 14:43                             ` Georg Bauhaus
2002-10-23  8:39                           ` Dmitry A. Kazakov
2002-10-23 14:39                             ` Georg Bauhaus
2002-10-24  8:18                               ` Dmitry A. Kazakov
2002-10-21 16:50                   ` Warren W. Gay VE3WWG
2002-10-21 15:20             ` Georg Bauhaus
2002-10-21 17:51               ` Programmer Dude
2002-10-21 18:48                 ` Jim Rogers
2002-10-21 19:44                   ` tmoran
2002-10-21 20:42                   ` Programmer Dude
2002-10-22  1:42                     ` Jeffrey Carter
2002-10-22 14:37                       ` Robert A Duff
2002-10-22 18:51                         ` Jeffrey Carter
2002-10-23  7:01                         ` Pascal Obry
2002-10-22 14:45                       ` Matthew Heaney
2002-10-22 18:47                         ` Jeffrey Carter
2002-10-22 21:31                         ` Robert A Duff
     [not found]                         ` <3DB59D75.20609 <wccd6q29n3l.fsf@shell01.TheWorld.com>
2002-10-23  2:02                           ` Jeffrey Carter
2002-10-23 13:16                             ` Matthew Heaney
2002-10-23 19:11                               ` Jeffrey Carter
2002-10-23 15:24                             ` Robert A Duff
2002-10-23 19:24                               ` Jeffrey Carter
2002-10-24  0:33                                 ` Robert A Duff
2002-10-22  3:46                     ` Jim Rogers [this message]
2002-10-22 14:48                       ` Robert A Duff
2002-10-22 15:02                         ` Fraser Wilson
2002-10-22 15:38                           ` David C. Hoos
2002-10-22 15:44                             ` Fraser Wilson
2002-10-22 16:13                         ` Robert A Duff
2002-10-23  8:58                           ` Dmitry A. Kazakov
2002-10-23  9:08                             ` Lutz Donnerhacke
2002-10-23  9:34                               ` Dmitry A. Kazakov
2002-10-23 10:10                                 ` Lutz Donnerhacke
2002-10-23 17:15                                 ` Frank J. Lhota
2002-10-24  8:41                                   ` Dmitry A. Kazakov
2002-10-24  9:25                                   ` Fraser Wilson
2002-10-24 14:13                                     ` Matthew Heaney
     [not found]                         ` <un <wcc7kgazc20.fsf@shell01.TheWorld.com>
2002-10-22 16:46                           ` David C. Hoos
2002-10-22  8:51                   ` Stuart Palin
2002-10-22 18:56                     ` Programmer Dude
2002-10-21 19:42                 ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2002-10-11  5:04 Grein, Christoph
2002-10-11 10:30 ` Preben Randhol
2002-10-23  5:15 Grein, Christoph
2002-10-23 13:19 ` Matthew Heaney
2002-10-24  5:53 Grein, Christoph
2002-10-24 14:04 ` Matthew Heaney
replies disabled

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