comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Problem with generic linked list package
Date: Sun, 10 Aug 2014 16:42:54 -0700
Date: 2014-08-10T16:42:54-07:00	[thread overview]
Message-ID: <ls901v$vng$2@dont-email.me> (raw)
In-Reply-To: <lyr40oknyg.fsf@pushface.org>

On 08/10/2014 02:57 PM, Simon Wright wrote:
>
> You have (after Shark8's suggestion, I think) a generic package which
> starts something like
>
>     generic
>        type T is private;
>        with function "<" (L, R : T) return Boolean is <>;
>     package P is

Specifically, a linked-list pkg, which only uses "<" for its Insert_In_Order 
subprogram. There are plenty of times when you want to keep things in a list and 
don't care about their order; this pkg requires that the client supply a "<" 
that will never be used in that case. And there are times when you want to 
allocate things like tasks and keep them in a data structure such as a linked 
list. There is no meaningful definition of "<" in such a case.

task type T;

type T_Ptr is access T;

How would one create a linked list of T_Ptr? One could fake up a "<" that 
returns True, but that's wasted effort.

The intention of my post which started off this sub-thread (about writing "<" 
for record types) was to get the OP thinking about how to write a linked-list 
pkg that would be useful for such a case (not requiring "<" to be instantiated) 
but still able to provide Insert_In_Order for cases where "<" is meaningful and 
an ordered list is desired.

-- 
Jeff Carter
"Little blondes with long hair and short skirts and
boots and big chests and bright, witty, and perceptive."
Play It Again, Sam
128

  reply	other threads:[~2014-08-10 23:42 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 13:26 Problem with generic linked list package Laurent
2014-07-29  7:51 ` Jacob Sparre Andersen
2014-07-29  8:12   ` Laurent
2014-07-29  8:27 ` Stephen Leake
2014-07-29 15:38   ` Laurent
2014-08-07 19:07     ` Laurent
2014-08-07 19:21       ` Adam Beneschan
2014-08-07 19:25         ` Adam Beneschan
2014-08-07 22:20           ` Laurent
2014-08-07 23:35             ` Adam Beneschan
2014-08-08  4:42               ` Laurent
2014-08-09 14:32                 ` Laurent
2014-08-09 14:58                   ` AdaMagica
2014-08-09 15:22                   ` Jeffrey Carter
2014-08-09 18:51                   ` Shark8
2014-08-09 21:53                     ` Laurent
2014-08-09 22:25                       ` Jeffrey Carter
2014-08-10  8:22                       ` Simon Wright
2014-08-10 10:45                         ` Simon Wright
2014-08-10 20:20                           ` Laurent
2014-08-10 21:57                             ` Simon Wright
2014-08-10 23:42                               ` Jeffrey Carter [this message]
2014-08-11  4:51                                 ` Laurent
2014-08-11  5:13                                   ` Jeffrey Carter
2014-08-11  7:56                                     ` Laurent
2014-08-07 20:37       ` Shark8
2014-08-07 22:30         ` Laurent
2014-08-07 23:22           ` Shark8
replies disabled

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