home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!cs.adelaide.edu.au!andrewd
- From: andrewd@cs.adelaide.edu.au (Andrew Dunstan)
- Newsgroups: comp.lang.ada
- Subject: Re: Could you forward this to Comp.Lang.Ada
- Message-ID: <8392@sirius.ucs.adelaide.edu.au>
- Date: 1 Sep 92 02:58:41 GMT
- References: <9208311113.AA21505@cs.NYU.EDU>
- Sender: news@ucs.adelaide.edu.au
- Lines: 46
- Nntp-Posting-Host: achilles.cs.adelaide.edu.au
-
- In article <9208311113.AA21505@cs.NYU.EDU>, dewar (Robert Dewar) writes:
- |> Andrew Dunstan writes:
- |> "Thanks for pointing this [the rule in 13.5(8)] out - I did actually look
- |> in the LRM before I posted, but obviously not hard enough! Finding these
- |> little things in the LRM is like looking for a needle in a haystack."
- |>
- |> Well the RM takes many knocks, some deserved, but really! this is somewhat
- |> unfair. If I was wondering about the use of an address clause in Ada, I
- |> should think I would read section 13.5 of the reference manual, whose
- |> title is, reasonably helpfully "Address Clauses". Since this section is
- |> quite short (only 21 lines long plus a short example and a note), it would
- |> seem quite reasonable to read the full 21 lines. 3 of these lines (a
- |> separate paragraph, para (5), contain the restriction stated pretty clearly:
- |>
- |> "Address clauses should not be used to achieve overlays of objects or
- |> overlays of program units. Nor should a given interrupt be linked to more
- |> than one entry. Any program using address clauses to achieve such an
- |> effect is erroneous."
-
- Ok, my face is bright red! I looked at 13.1 and missed the reference to 13.5.
-
-
- |>
- |> One final note, back to the original problem. The best general solution is
- |> to use access STRING for these kind of situations. Actually access STRING
- |> is a pretty reasonable type for the manipulation of variable length strings.
- |> Of course it means using the heap which you might want to avoid, but in that
- |> case, worry a little about using unconstrained returned values from functions
- |> at all -- many, but not all, implementations secretly use the heap anyway
- |> for this situation. So if you are writing portable code which wants to avoid
- |> using the heap, better to use an interface like GET_LINE, even if it is
- |> clunkier!
-
- I have made the point to several people that using an access to string type
- is what I would do myself, but that I have seen code which does use
- address clauses to do what I suggested, notwithstanding that it is
- erroneous.
-
- --
- #######################################################################
- # Andrew Dunstan # There's nothing good or bad #
- # Department of Computer Science # but thinking makes it so. #
- # University of Adelaide # #
- # South Australia # - Shakespeare #
- # net: andrewd@cs.adelaide.edu.au # #
- #######################################################################
-