comp.lang.ada
 help / color / mirror / Atom feed
From: andrewd@cs.adelaide.edu.au (Andrew Dunstan)
Subject: Re: generic queue packages
Date: 28 Feb 93 00:20:51 GMT
Date: 1993-02-28T00:20:51+00:00	[thread overview]
Message-ID: <1mp0h3INNp2u@huon.itd.adelaide.edu.au> (raw)
In-Reply-To: 1993Feb26.190255.24811@seas.gwu.edu

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  #                                 #
#######################################################################



  reply	other threads:[~1993-02-28  0:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-02-24 21:26 generic queue packages John Goodsen
1993-02-26  3:16 ` enterpoop.mit.edu!spool.mu.edu!howland.reston.ans.net!zaphod.mps.ohio-sta
1993-02-26 19:02   ` Michael Feldman
1993-02-28  0:20     ` Andrew Dunstan [this message]
1993-02-28  5:31       ` Michael Feldman
  -- strict thread matches above, loose matches on Subject: below --
1993-02-22 15:32 pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!nntpd2.cxo.dec.com!etre!w
1993-02-09 19:04 cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!h
replies disabled

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