comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jeffrey.carter@boeing.com>
Subject: Re: List Strawman JC01
Date: Thu, 6 Dec 2001 00:14:09 GMT
Date: 2001-12-06T00:14:09+00:00	[thread overview]
Message-ID: <3C0EB851.77E7172A@boeing.com> (raw)
In-Reply-To: smuP7.50028$xS6.82871@www.newsranger.com

Ted Dennison wrote:
> 
> In article <3C0DB9D0.7184868A@acm.org>, Jeffrey Carter says...
> >
> >some alternative naming conventions for consideration.
> >   type List_Handle is private; -- Initial value: Empty
> >   -- [Keep the name List for parameters]
> 
> I'm not a fan of the style where one adds a meaningless word like "Type" or
> "Handle" to the end of identifiers to save name space for other uses. Types
> should be named describing the general concept of what they represent, and
> objects and parameters should be given names describing their explicit role in
> the system.

I agree. And since List is a better parameter name than Target or
whatever for many operations, I choose to keep it available for a
parameter name. This means the type has to have a different name. In any
case, we're deliberately trying out different names to see which ones
cause the fewest people to barf.

> 
> >   -- Time: O(N)
> 
> I'd agree that this needs to be documented for the routines. However, it might
> be better to put this information in a matrix in the parent pacakge so that
> users can judge the various container package's performances against each other
> when deciding which one to use.

Except we're talking about one package for unbounded lists. In the case
of this strawman, there's no parent package.

> >   -- [Apparently unneeded List_Handle parameters are supplied
> >   -- to some operations in case they're needed for safety.]
> 
> If we don't go to completely "safe" iterators, perhaps. With completely safe
> iterators, its pretty pointless (all it does is give the user another way to
> screw up the call). The current version of the Strawman uses the safe approach,
> so the List type need not be supplied after the iterator is constructed.

The degree of safety is the undecided requirement. This notation allows
implementations with different degrees of safety; when we decide on
that, we can decide what notation to adopt. If we want a bounded list
package at some point with similar semantics, we probably will need list
parameters.

> 
> >   Storage_Exhausted : exception;
> 
> Why is this considered superior to STORAGE_ERROR? Do you have plans to do
> something here other than just handle STORAGE_ERROR and raise Storage_Exhausted?

As a general principle, a package should not be propagating predefined
exceptions to its clients. Also, this helps allow differing
implementations. If Storage_Error comes out of a list instead of
Storage_Exhausted, there's an error in the implementation, and the
difference helps you find it.

> 
> >   generic -- Sort
> >      with function "<" (Left : Element; Right : Element)
> 
> I really don't like this name, as it gets quite confusing what is going on when
> "<" is not used for the actual. (In fact, without the comment, I'd have little
> clue what is going on either way). I'd rather see the function named after
> either what it wants done or what condition exists relative to general sorting
> when TRUE is returned.
> 
> >   -- Sorts List into ascending order as defined by "<"
> 
> Perfect example here. What precisely does "ascending order as defined by "<""
> mean? I *still* don't know if supplying ">" will sort in ascending or decending
> order when iterated in the direction I like to iterate, based on the routine
> name and this comment.
> 
> For a code reader its even worse, because all they will see is:
> 
> Foo_Sort is new Sort ("<" => ">");
> 
> Their reaction is liable to be roughly "WTF?" On the other hand, if they see
> 
> Foo_Sort is new Sort (Swap_Items => ">");
> 
> ..then at least its clear to the reader that the sort will consider things out
> of order when the first item is greater than the second.

This is much less clear than "<". Everyone knows what "<" does.
"Swap_Items (L, R ...) return Boolean;" is meaningless.

> 
> We still have a bit of a problem here, as "First" and "Second" (or "Left" and
> "Right") aren't very well defined in this context. Is the "Front" of the list on
> the left or the right? Does "Sort" sort towards the front or the back?

Is the array

(1, 2, 3, 4)

in ascending order? The answer is obvious to most people, because an
array is a sequence.

Order in a list (or any other sequence) is very well defined. There's
the First element, the Next element, the Next element, ... , the Last
element. A list is sorted in ascending order according to "<" if no
element is less than ("<") a preceding element.

First and Second are perfectly well defined for a list. The first
element in List is designated by First (List); the second by Next (First
(List) ), and so on.

I note that I omitted an essential function from this specification:
"=". Please assume the following was part of the package:

generic -- "="
   with function "=" (Left : Element; Right : Element) return Boolean is
<>;
function "=" (Left : List_Handle; Right : List_Handle) return Boolean;
-- Two lists are equal if they have the same Length and have equal
Elements at
-- corresponding positions.

-- 
Jeffrey Carter



  reply	other threads:[~2001-12-06  0:14 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-05  6:08 List Strawman JC01 Jeffrey Carter
2001-12-05 19:14 ` Ted Dennison
2001-12-06  0:14   ` Jeffrey Carter [this message]
2001-12-06  3:15     ` Jeffrey Carter
2001-12-06 16:11     ` Ted Dennison
2001-12-06 17:48       ` Jeffrey Carter
2001-12-07 15:06         ` Ted Dennison
2001-12-07 17:43           ` Stephen Leake
2001-12-07 18:59             ` Ted Dennison
2001-12-09 14:04               ` Mark Lundquist
2001-12-10 15:25                 ` Ted Dennison
2001-12-10 15:46               ` Marin David Condic
2001-12-10 17:12                 ` Ted Dennison
2001-12-07 18:10           ` Jeffrey Carter
2001-12-07 19:45             ` Ted Dennison
2001-12-07 22:47               ` Basic Properties of Lists Jeffrey Carter
2001-12-09 14:04                 ` Mark Lundquist
2001-12-09 18:16                   ` Chad R. Meiners
2001-12-09 21:21                   ` Jeffrey Carter
2001-12-10 15:37                   ` Ted Dennison
2001-12-10 22:13                     ` Jeffrey Carter
2001-12-11 14:33                       ` Ted Dennison
2001-12-09 14:04           ` List Strawman JC01 Mark Lundquist
2001-12-10 17:02             ` Ted Dennison
2001-12-10 17:13               ` Ted Dennison
2001-12-10 15:37           ` Marin David Condic
2001-12-10 16:10             ` Larry Hazel
2001-12-06 19:09       ` Stephen Leake
2001-12-06 22:45         ` Jeffrey Carter
2001-12-07 16:54           ` Ted Dennison
2001-12-07 17:18             ` Darren New
2001-12-07 17:44               ` Doubly-linked list ordering(s) (was: List Strawman JC01) Ted Dennison
2001-12-07 17:30         ` List Strawman JC01 Ted Dennison
2001-12-06 19:34     ` Mark Lundquist
2001-12-07 17:04       ` Ted Dennison
2001-12-07 22:27         ` Jeffrey Carter
2001-12-09 14:04         ` Mark Lundquist
2001-12-06 19:34   ` Mark Lundquist
2001-12-06 23:09 ` Nick Roberts
replies disabled

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