comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ijs.co.nz>
Subject: Re: Modes (was unbounded_string)
Date: Wed, 15 Oct 2003 07:47:59 +1300
Date: 2003-10-15T07:47:59+13:00	[thread overview]
Message-ID: <l2doovsm21l7ft560tqascm8hremoe28jh@4ax.com> (raw)
In-Reply-To: uzng9f7ej.fsf@nasa.gov


On 10 Oct 2003 11:18:28 -0400, Stephen Leake wrote:
>"Andrew Carroll" wrote:
...
>Tagged types and full limited types are always passed by reference,
>because it almost always matters for them.
...

Not really true.
It could be if AARM/RM 12.4(8) was deleted:

  12.4 Formal Objects
    (8.) The type of a generic formal object of mode in shall be
       nonlimited.
    (8.a) Reason: Since a generic formal object is like a constant
       of mode in initialized to the value of the actual, a
       limited type would not make sense, since initializing a
       constant is not allowed for a limited type. That is, generic
       formal objects of mode in are passed by copy, and limited
       types are not supposed to be copied.
   http://www.adaic.org/standards/95aarm/html/AA-12-4.html

Excerpt from AI-00318 ("Returning [limited] objects without copying"):

| From: Randy Brukardt
| Sent: Thursday, February 7, 2002,  3:05 PM
|
| Here is an example that came up in Claw where we really wanted
| constants of a limited type:
|
| [...] its the original problem all over again), so we had to turn that
| into a variable and initialize it component-by-component in the package
| body's elaboration code:
|
|       Standard_Classes_Root : Key_Type;
|
|       function Classes_Root return Key_Type is
|       begin
|          return Standard_Classes_Root;
|       end Classes_Root;
|
|    begin
|       Standard_Classes_Root.Handle := 16#80000000#;  -- Magic number
|       Standard_Classes_Root.Predefined_Key => True;
|       ...
|
| Which is essentially how it is today.
|
| This turned into such a mess that we gave up deriving from it altogether,
  ...
|
| I certainly hope that newcomers to Ada don't run into a problem like this,
| because it is a classic "stupid language" problem.
|
| Simply having a way to initialize a limited constant with an aggregate
| would be sufficient to fix this problem. "Constructor functions" might
| add orthogonality, but seem unnecessary to solve the problem of being
| able to have constants as part of an abstraction's specification.
|

To bypass the restriction of 12.4(8), an "access constant" [read-only]
pointer to the "aliased" unchanging variable would be passed in:


   generic
      type Number is limited private;    --  "limited" stops assigning

      Zero        : in Num;  --  Illegal.
                          --  Here is a workaround:
      type Num_Const_Ptr is access constant Num;
      Zero        :  Num_Const_Ptr;
      ...
   package

Here is some text from AI-00287 (topic "Limited Aggregates Allowed"):

| How do you capture the result of a function call?  You put it in a
| constant: "X: constant T := F(...);". But if it's limited, you have to
| *rename* it: "X: T renames F(...);". Again, that's not something that
| would naturally occur to a beginner -- and the beginner would rightly
| look upon it as a "trick" or a "workaround".




>You can't specify the parameter passing mechanism, except by making
>the type tagged or fully limited.

What about putting "aliased" keyword into the record's definition(?).

----

Corrupted elections in USA:

   http://news.independent.co.uk/world/americas/story.jsp?story=452972


  "some of the code downright suspect - for example, an overtly
   meaningless instruction to divide the number of write-in votes by 1.
   ...
  "Most suspect of all was the governor's race in Alabama, where the
   incumbent Democrat, Don Siegelman, was initially declared the winner.
   Sometime after midnight, when polling station observers and most staff
   had gone home, the probate judge responsible for elections in rural
   Baldwin County suddenly "discovered" that Mr Siegelman had been
   awarded 7,000 votes too many. ... the change was enough to hand
   victory to his Republican challenger, ... the state's Republican
   attorney general refused to authorise a recount or any independent
   ballot inspection."

The San Mateo county assessor (Slocum) has some information on
the need for correct and verificable results from USA elections:

   http://www.warrenslocum.com/





  parent reply	other threads:[~2003-10-14 18:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20031010074015.761204C40C1@lovelace.ada-france.org>
2003-10-10  8:27 ` Modes (was unbounded_string) Andrew Carroll
2003-10-10  9:15   ` Dmitry A. Kazakov
2003-10-11  7:16     ` Simon Wright
2003-10-13  9:28       ` Dmitry A. Kazakov
2003-10-10 15:18   ` Stephen Leake
2003-10-10 16:21     ` Martin Dowie
2003-10-14 18:47     ` Craig Carey [this message]
2003-10-10 19:06   ` Jeffrey Carter
2003-10-13  9:33     ` Dmitry A. Kazakov
2003-10-13  9:40       ` Stephane Richard
2003-10-13 10:12         ` Dmitry A. Kazakov
2003-10-15  2:16         ` Warren W. Gay VE3WWG
2003-10-15  3:36           ` Jeff C,
2003-10-16 16:45             ` Warren W. Gay VE3WWG
     [not found] <20031010094017.680474C40C1@lovelace.ada-france.org>
2003-10-10 10:58 ` Andrew Carroll
replies disabled

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