comp.lang.ada
 help / color / mirror / Atom feed
* Re: Access types and ALL
@ 1992-04-21 19:52 elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!ub!dsinc!netnews.upenn.e
  0 siblings, 0 replies; only message in thread
From: elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!ub!dsinc!netnews.upenn.e @ 1992-04-21 19:52 UTC (permalink / raw)


In article <1992Apr14.204743.19499@u.washington.edu>, mfeldman@milton.u.washing
ton.edu (Michael Feldman) writes:

Mike presents the following example,

|> Given a record type 
|> 
|>   TYPE R IS RECORD
|>     ...
|>     F: Some_Type := Some_Value;
|>     ...
|> 
|>   END RECORD;
|> 
|> and an access type 
|> 
|>   TYPE R_Ptr IS ACCESS R;
|> 
|>   ...
|> 
|>   RP : R_Ptr := NEW R;
|> 
|> we can apparently select the field F in two ways:
|> 
|>   (1) RP.F
|> 
|>   (2) RP.ALL.F
|> 

I wonder to what extent this anomoly is due to the desire of the language desig
ners to 
make some of Ada not look like Pascal, resulting in the decision not to use the
 '^'
to distinguish between an access variable and the object pointeed to by the acc
ess 
variable.  Once the '^' disappeared, the need for ".all" arise.  To illustrate,
 if

            RP, QP : R_Ptr ;

then               [in Ada]                                         [in Pascal]

            QP := RP ;  --  copy the access variable value           QP    := R
P ;

            QP.all := RP.all ; -- copy the object being pointed to   QP^   := R
P^ ;

            QP.all.F := RP.F   -- looks like a mistake               QP^.F := R
P^.F ;

Since were stuck with Mike's anomoly, I guess we need a style rule, like

"only use .all when you really have to!?".  ".all" things considered, I'll stil
l
take Ada.
-- 
+-----------------------------------------------------------------------------+
|  John (Jack) Beidler				                              |
|  Prof. of Computer Science  Internet (VAX/VMS)  BEIDLER@JAGUAR.UOFS.ED      |
|  University of Scranton     Internet (SUN/UNIX) BEIDLER@GUINNESS.CS.UOFS.EDU|
|  Scranton, PA 18510	      Bitnet   (VAX/VMS)  BEIDLER@SCRANTON            |
|                                                                             |
|          Phone: (717) 941-7446	 FAX:   (717) 941-4250                |
+-----------------------------------------------------------------------------+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1992-04-21 19:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-21 19:52 Access types and ALL elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!ub!dsinc!netnews.upenn.e

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