comp.lang.ada
 help / color / mirror / Atom feed
* Systemless use of 'Address.
@ 1994-11-10 15:14 Bob Wells #402
  1994-11-11 20:32 ` Cary Jamison
  1994-11-14 21:36 ` Norman H. Cohen
  0 siblings, 2 replies; 8+ messages in thread
From: Bob Wells #402 @ 1994-11-10 15:14 UTC (permalink / raw)


G'day,

Given the following procedure declaration:

  procedure Display_Code2String (
    Data_Address : in     System.Address;
    Data_Size    : in     Natural;
    Data         : in out String_Ptr;
    Length       : in out Natural;
    Append       : in     Boolean := False);


and the following call to the procedure

        Draw.Display_Code2String ( Data_Address => Tmp_String'Address,
                                   Data_Size    => Tmp_String'Size,
                                   Data         => Return_String,
                                   Length       => Return_String_Length );

Why does the Verdix compiler (sorry specifically the

Verdix Ada Compiler, Copyright 1984, 1992
VADSworks for Sun-4 -> MC68020/30/vxWorks, (VADS 6.0.5)
Mon Aug 17 09:11:00 EST 1992 2.0.3(b)

accept this procedyre call **without** the a with clause for the package
System?

But if I add

        Tmp_String : EDD_Code_String ( 1 .. (Integer(Tmp_Seq.All'Last)/3 + 1));
        for Tmp_String use at Tmp_Seq.All'Address;

it now will only compile the package without errors if I "with" System?

Am I missing something here?

Thanks,

BTW I haven't forgotten the request for Ada ATC info Mike. I'll get back to
you as soon as I can.

@                   --------
@          ////  - ( G'day! )
@         (o o)     --------
@ ----oOO--(_)--OOo--------------------------------------------------------
  Bob Wells         "The marvels of today's modern technology include the
                     development of a soda can, when discarded will last
                     forever ... and a $7,000 car which when properly cared
                     for will rust out in two or three years."
@ INTERNET: wel@eurocontrol.de                 CompuServe:      100272,3004
@ The Ada WWW Server is http://lglwww.epfl.ch/Ada/                 Team Ada
@ For exciting Ada info enter 'finger wel@s4ecawel.eurocontrol.de'



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

* Re: Systemless use of 'Address.
  1994-11-10 15:14 Systemless use of 'Address Bob Wells #402
@ 1994-11-11 20:32 ` Cary Jamison
  1994-11-12 20:38   ` Robert Dewar
  1994-11-14 21:36 ` Norman H. Cohen
  1 sibling, 1 reply; 8+ messages in thread
From: Cary Jamison @ 1994-11-11 20:32 UTC (permalink / raw)


In article <9411101514.AA21438@eurocontrol.de>, Bob Wells #402
<wel@EUROCONTROL.DE> wrote:

> G'day,
> 
> Given the following procedure declaration:
> 
>   procedure Display_Code2String (
>     Data_Address : in     System.Address;
>     Data_Size    : in     Natural;
>     Data         : in out String_Ptr;
>     Length       : in out Natural;
>     Append       : in     Boolean := False);
> 
> 
> and the following call to the procedure
> 
>         Draw.Display_Code2String ( Data_Address => Tmp_String'Address,
>                                    Data_Size    => Tmp_String'Size,
>                                    Data         => Return_String,
>                                    Length       => Return_String_Length );
> 
> Why does the Verdix compiler (sorry specifically the
> 
> Verdix Ada Compiler, Copyright 1984, 1992
> VADSworks for Sun-4 -> MC68020/30/vxWorks, (VADS 6.0.5)
> Mon Aug 17 09:11:00 EST 1992 2.0.3(b)
> 
> accept this procedyre call **without** the a with clause for the package
> System?
> 
[...]

I've noticed something similar for SunAda 2.1 (Verdix version???).  When
using the Language package, I forgot to with it in some cases, but the
compiler only gave me warnings instead of errors.

-- 
Cary Jamison
cary@svl.trw.com



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

* Re: Systemless use of 'Address.
  1994-11-11 20:32 ` Cary Jamison
@ 1994-11-12 20:38   ` Robert Dewar
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1994-11-12 20:38 UTC (permalink / raw)


Actually I don't see why you would expect a "with" of System to be required,
since no entity from system is mentioned, and hence accessibility to
System is not required.

The use of the 'Address attribute in the absence of visibility into System
is certainly a little peculiar. A strict reading of 1815 probably indicates
that there is no requirement for package system to be present, but this is
obviously peculiar, and AI-00043/08-BI-WA addresses this issue by requiring
that the unit using 'Address must depend directly or indirectly on System
(but still does not require an explicit with of system). Ada 9X makes this
rule a clear part of the language.

Note: I stronly recommend having at hand a copy of the Annotated Ada
Reference Manual from Karl Nyberg if you are still using Ada 83. It's well
layed out, and allows you to answer questions like this, complete with 
appropriate AI references, easily.




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

* Re: Systemless use of 'Address.
  1994-11-10 15:14 Systemless use of 'Address Bob Wells #402
  1994-11-11 20:32 ` Cary Jamison
@ 1994-11-14 21:36 ` Norman H. Cohen
  1994-11-16 16:11   ` Mats Weber
  1 sibling, 1 reply; 8+ messages in thread
From: Norman H. Cohen @ 1994-11-14 21:36 UTC (permalink / raw)


In article <9411101514.AA21438@eurocontrol.de>, Bob Wells #402
<wel@EUROCONTROL.DE> writes: 

|> G'day,
|>
|> Given the following procedure declaration: 
|>
|>   procedure Display_Code2String (
|>     Data_Address : in     System.Address;
|>     Data_Size    : in     Natural;
|>     Data         : in out String_Ptr;
|>     Length       : in out Natural;
|>     Append       : in     Boolean := False);
|>
|>
|> and the following call to the procedure
|>
|>         Draw.Display_Code2String ( Data_Address => Tmp_String'Address,
|>                                    Data_Size    => Tmp_String'Size,
|>                                    Data         => Return_String,
|>                                    Length       => Return_String_Length );
|>
|> Why does the Verdix compiler (sorry specifically the
|>
|> Verdix Ada Compiler, Copyright 1984, 1992
|> VADSworks for Sun-4 -> MC68020/30/vxWorks, (VADS 6.0.5)
|> Mon Aug 17 09:11:00 EST 1992 2.0.3(b)
|>
|> accept this procedyre call **without** the a with clause for the package
|> System?
|>
|> But if I add
|>
|>         Tmp_String : EDD_Code_String ( 1 .. (Integer(Tmp_Seq.All'Last)/3 + 1));
|>         for Tmp_String use at Tmp_Seq.All'Address;
|>
|> it now will only compile the package without errors if I "with" System?

AI-00043, a binding interpretation approved by WG9 in June 1990, states,
"The attribute ADDRESS can only be used in compilation unit if a with
clause naming the predefined package SYSTEM has been given either for the
compilation unit itself or for a compilation unit on which the current
unit depends (directly or indirectly)."

Did you add the address clause to the same compilation unit that had
the procedure call, or are they two different units?  If they are two
different units, it could be that the unit containing the procedure call,
even though it did not have its own with clause for System, depended on
some unit that did have such a with clause.  According to the AI, it is
sufficient to have a with clause for a unit that has a with clause for a
unit that has a with clause for a unit that has a with clause for System.

--
Norman H. Cohen    ncohen@watson.ibm.com



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

* Re: Systemless use of 'Address.
  1994-11-14 21:36 ` Norman H. Cohen
@ 1994-11-16 16:11   ` Mats Weber
  1994-11-16 23:50     ` Robert Dewar
  1994-11-17  1:41     ` Bob Duff
  0 siblings, 2 replies; 8+ messages in thread
From: Mats Weber @ 1994-11-16 16:11 UTC (permalink / raw)


How is it with the 'Unchecked_Access attribute in Ada 9X ? Does it require
with System ? (I think it should).



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

* Re: Systemless use of 'Address.
  1994-11-16 16:11   ` Mats Weber
@ 1994-11-16 23:50     ` Robert Dewar
  1994-11-17 22:35       ` Keith Thompson
  1994-11-17  1:41     ` Bob Duff
  1 sibling, 1 reply; 8+ messages in thread
From: Robert Dewar @ 1994-11-16 23:50 UTC (permalink / raw)


Why on earth should unchecked_access require system? it has nothing to do
with entities declared in system, and its semantics is not system
dependent.

Sure it can be used to construct erroneous programs whose behavior is
implementation dependent, but hey, you can do that with uninitialized
variables, and you don't have to with system to create those!




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

* Re: Systemless use of 'Address.
  1994-11-16 16:11   ` Mats Weber
  1994-11-16 23:50     ` Robert Dewar
@ 1994-11-17  1:41     ` Bob Duff
  1 sibling, 0 replies; 8+ messages in thread
From: Bob Duff @ 1994-11-17  1:41 UTC (permalink / raw)


In article <Mats.Weber-1611941711120001@mlma11.matrix.ch>,
Mats Weber <Mats.Weber@matrix.ch> wrote:
>How is it with the 'Unchecked_Access attribute in Ada 9X ? Does it require
>with System ?

No.

> ...(I think it should).

To me, it would seem strange to have such a requirement.
'Unchecked_Access doesn't have any operand or result of a type in
package System, nor relate to System in any other way.

- Bob
-- 
Bob Duff                                bobduff@inmet.com
Oak Tree Software, Inc.
Ada 9X Mapping/Revision Team (Intermetrics, Inc.)



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

* Re: Systemless use of 'Address.
  1994-11-16 23:50     ` Robert Dewar
@ 1994-11-17 22:35       ` Keith Thompson
  0 siblings, 0 replies; 8+ messages in thread
From: Keith Thompson @ 1994-11-17 22:35 UTC (permalink / raw)


In <3ae5s0$o1p@gnat.cs.nyu.edu> dewar@cs.nyu.edu (Robert Dewar) writes:
> Why on earth should unchecked_access require system? it has nothing to do
> with entities declared in system, and its semantics is not system
> dependent.

Several other "unsafe" Ada constructs require an explicit "with".  Address
clauses require a "with" of System, instantiations of Unchecked_Conversion
and Unchecked_Deallocation require a "with" of the respective generic
subprogram, machine code insertions require a "with" of Machine_Code.
(Note, however, that calls to instances of Unchecked_Conversion and
Unchecked_Deallocation don't require a direct "with".)

The purpose is to flag a compilation unit that uses these unsafe
constructs in a highly visible way.

It would be consistent with this policy to require an explicit "with"
before using 'Unchecked_Access, but there's no clean way to add such
a requirement, since the 'Unchecked_Access attribute doesn't depend on
anything declared in any particular predefined unit.

I suppose the language could have defined something like this:

   generic
      type Object is limited private;
      type Name   is access all Object;
   function Unchecked_Access(X: Object) return Name;

(I *think* that's right.)

The drawbacks of this would be that it's less convenient (which I might
argue is a good thing), and that it draws attention to instantiations
and not to calls.

Of course, you can always scan the source file for the identifier
Unchecked_Access, so marking the context clause probably isn't such a
big deal anyway.

> Sure it can be used to construct erroneous programs whose behavior is
> implementation dependent, but hey, you can do that with uninitialized
> variables, and you don't have to with system to create those!

There's a difference between code that's unintentionally erroneous (i.e.,
buggy) and code that's deliberately "unsafe".  It's reasonable to make
the user work harder to write unsafe code.  It would be nice to make
it difficult or impossible to write buggy code, but that's beyond the
current state of the art.

In any case, I'm sure it's far to late in the Ada 9X process to
contemplate this kind of change.

-- 
Keith Thompson (The_Other_Keith)  kst@alsys.com
TeleSoft^H^H^H^H^H^H^H^H Alsys, Inc.
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
/user/kst/.signature: I/O error (core dumped)



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

end of thread, other threads:[~1994-11-17 22:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-11-10 15:14 Systemless use of 'Address Bob Wells #402
1994-11-11 20:32 ` Cary Jamison
1994-11-12 20:38   ` Robert Dewar
1994-11-14 21:36 ` Norman H. Cohen
1994-11-16 16:11   ` Mats Weber
1994-11-16 23:50     ` Robert Dewar
1994-11-17 22:35       ` Keith Thompson
1994-11-17  1:41     ` Bob Duff

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