From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d321b3a6b8bcab2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-20 01:33:47 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!fnnews.fnal.gov!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!news.sprintlink.net!pipex!uknet!hrc63!gmrc.gecm.com!valiant!bill From: bill@valiant (R.A.L Williams) Newsgroups: comp.lang.ada Subject: "Subtract C, add Ada" Date: 20 Jan 1995 09:33:47 GMT Organization: GEC-Marconi Research Centre Message-ID: <3fo01r$su2@miranda.gmrc.gecm.com> NNTP-Posting-Host: valiant.gmrc.gecm.com X-Newsreader: TIN [version 1.2 PL1] Date: 1995-01-20T09:33:47+00:00 List-Id: [Our news system broke down earlier this week so I don't know whether this message got out. If it did I apologise for the wasted bandwidth. Bill Williams] Robert Dewar wrote.. > Bill comments that for his points 3. and 4. > > 3. uninitialised pointer access > 4. pointer references to local variables in defunct procedures > > "The syntax of Ada .. does not really address 3. or 4." > > Taking point 3, it is impossible to have an uninitialized pointer in Ada, > all pointers are initialized to null, and any attempt to use a null pointer, > i.e. to dereference it, will cause a constraint error. Seems like pretty > complete protection to me. Yes, you're right, Ada *guarantees* a run time crash, in C/C++ it's just very likely. It's still not a compile time check so you're relying on the quality of your run time environment to tie down where the problem occurs. Of course, in embedded systems you don't want *any* exceptions, no matter how cleanly you handle them! I'm not saying that we necessarily want to go to a language which either doesn't allow pointers (yuck!) or constrains their use to such an extent that compile time checks are feasible; I was just trying to point out that using Ada is no substitute for good engineering practice in design and coding. > With regard to point 4, ther is no way to get pointer references to local > variables in Ada 83 (except use of 'Address, and non-portable maybe-works, > maybe-doesn't unchecked conversion of the address to an access type, which > really doesn't count). Certainly students (and most other Ada programmers) > should be forbidden from using such constructs (the use of 'Address, and > indeed of unchecked conversion of addresses to access types is permissible > in some situations, but taking the 'Address of locals in a subprogram is > pretty dubious). Again, you're right BUT, 'ADDRESS is something you need to do fairly often when interfacing to foreign languages. Sorry, don't want to start a religious argument about libraries etc. it's just a fact of life. I agree whole heartedly about restricting the constructs used by 'novice' programmers or those coding for `critical' environments. > In Ada 95, it is indeed possible to take the 'Access of local variables, > provided they are marked aliased, but the accessibility rules make it > impossible to have dangling pointers. Dangling pointers can be created > by the use of Unchecked_Access, but this is in the same category as > Unchecked_Conversion, to be used with great care in rare cases. I'm looking forward to trying out Ada95. Got GNAT 2.0 up and going on a SPARC station that I have occasional access to. I'm really looking forward to the HP700 port because that's what our local network is. Thanks for the feedback. Bill Williams