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,5a817e6528505e97 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-02-27 16:20:51 PST Path: sparky!uunet!decwrl!pagesat!olivea!spool.mu.edu!agate!dog.ee.lbl.gov!network.ucsd.edu!munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!cs.adelaide.edu.au!andrewd From: andrewd@cs.adelaide.edu.au (Andrew Dunstan) Newsgroups: comp.lang.ada Subject: Re: generic queue packages Message-ID: <1mp0h3INNp2u@huon.itd.adelaide.edu.au> Date: 28 Feb 93 00:20:51 GMT References: <1993Feb24.212641.8326@evb.com> <1993Feb26.031650.3447@leeweyr.sccsi.com> <1993Feb26.190255.24811@seas.gwu.edu> Organization: The University of Adelaide NNTP-Posting-Host: achilles.cs.adelaide.edu.au Date: 1993-02-28T00:20:51+00:00 List-Id: In article <1993Feb26.190255.24811@seas.gwu.edu>, mfeldman@seas.gwu.edu (Michael Feldman) writes: [he dislikes] |> TYPE Stupid (Length: Positive := 8) IS RECORD |> String_Part: String(1..Length); |> END RECORD; |> [he prefers] |> |> SUBTYPE Realistic IS Integer RANGE 1..64; -- for example |> TYPE Smart (Length: Realistic := 8) IS RECORD |> String_Part: String(1..Length); |> END RECORD; |> |> will waste at most 64 characters' worth, whether the compiler chooses |> static or dynamic allocation. That's a whole lot better than the |> roughly 2 gigabytes you'd try to allocate for a record of the first |> type, if the compiler used static allocation and Integer was 32 bits. |> (TeleSoft and Verdix do this, for example.) So it's (more) portable. |> |> Variant records are a GREAT way to test intelligent design decisions. |> Don't blame bad ones on the language or the compiler, friends. |> |> Mike Feldman A "realistic" maximum might still be quite large. Say we allow lines up to 255 chrs. Storage of 100,000 lines of average length 10 will still waste megabytes of memory if a static allocation strategy is used by the compiler. That is why I generally avoid this sort of use of variant records for this sort of processing - if I want dynamic sizing I make it explicit by doing it myself - that makes for portable code. It also means I don't have to use arbitrary limits on the size of some structure. -- ####################################################################### # Andrew Dunstan (formerly of the) # 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 # # #######################################################################